Is there a way to disable a component, like LineRenderer, when [RequireComponent] is used? Im trying to have it so when I attach my base script and it attaches all of the components, it sets them as disabled in the inspector as default.
using UnityEngine;
[RequireComponent(typeof(LineRenderer))]
public class ProjectileController : MonoBehaviour
{
[SerializeField] private ProjectileConfig projectileConfig = new ProjectileConfig();
private Ray shootRay;
private RaycastHit shootHit;
private LineRenderer gunLine;
}
This does not apply to my issue. I had checked it out. My script uses the [RequireCOmponent] attribute to ensure a LineRenderer is on the GO, but I am trying to have it make the LineRenderer automatically disabled in the inspector when the code is compiled as I go back into Unity. I tried using a constructor, but that didn't work.
– ZionmooseWell then maybe take out the Require Component? Also it should still allow you to disable the component even if it is " required". Maybe include your scripts to make this easier to understand?
– FanttumBasic code was updated. What I am trying to do is have the LineRenderer attach automatically to the GO when the ProjectileController gets attached. But I want the linerenderer to be attached as disabled if that is possible.
– Zionmoose