- Home /
Make variable visible in inspector
I have class (inherited from monobehaviour) with public variable of type "Item", it's also my custom class, but not inherited from monobehaviour (and must not, in my understanding of my project structure), so i can't make this variable visible in inspector, so i can set which "item" i want to be in object with this script from start, any solutions?
asiign thevariable via script, not via inspector...
Use resources.loadi f its aprefab, or GameObject.Find or FindObjectWithTag if its a scene object.
Answer by Nordicus666 · May 15, 2019 at 12:22 PM
moderating here was too long, i already got answer on other forum, answer is: make non-inherited class inherited from ScriptableObject and then use CreateAssetMenu so i can choose which object i want to be in my monobehaviour script
Answer by fafase · May 15, 2019 at 09:06 AM
You need to attach the Serializable attribute
[System.Serializable]
public class MyClass
{
public int value; // will show
[SerializeField] private int serPrivValue; // will show
[SerializeField] private int serProtValue; // will show
private int privValue; // will not show
protected int protValue; // will not show
}
This is ok if the Item is something that belongs to the $$anonymous$$onobehaviour class in question. If you want your Item to be an independent thing which you can hook up to different gameobjects, but you don't want Items to be $$anonymous$$onobehaviours themselves, then you almost certainly want to be making them into ScriptableObjects.
Your answer
Follow this Question
Related Questions
3D game kit Ellen / Show Player Input script variables on the inspector, 0 Answers
How to READ a variable VALUE from other Object Script? 1 Answer
How do I get an object to send a value to a manager script using an ontriggerenter? 1 Answer
How do I attach a GameObject to a static variable? 1 Answer
Custom Inspector Variables 1 Answer