Hey,
I’m creating a custom component for a unity asset. Instantiating public instances of it without being added as a component will break functionality.
I know Unity already helps by adding a warning when a MonoBahaviour is instantiated that way.
But I would like to completely block it the way a Transform does.
For instance, if you go.
Transform transform = new Transform();
You will get an error…
Transform.Transform()' is inaccessible due to its protection level
I looked into the code of the Transform component, and what seems to do it as a constructor…
public class Transform : Component, IEnumerable
{
protected Transform();
...
I tried doing that on my own component but I got an error…
SelectableObjectRTS.SelectableObjectRTS()' must declare a body because it is not marked abstract, extern, or partial
However the Transform does not seem to, plus things like abstract would break in unity.
Any help will be appreciated