- Home /
Problem exposing public variable to Inspector in C#
Hi
I've looked through the posts with a similar problem, don't seem to deal with what is happening here, well if they do trying the solution proposed hasn't worked.
I am putting in a public string variable that I wish to expose to the inspector. Basically I am changing a NGUI script putting in the variavle 'public string objectTagName' as follows.
[AddComponentMenu("NGUI/Examples/Drag & Drop Surface")]
public class DragDropSurface : MonoBehaviour {
public bool rotatePlacedObject = false;
public string objectTagName;
void OnDrop (GameObject go)
{
DragDropItem ddo = go.GetComponent();
if (ddo != null && ddo.tag == "Player")
{
GameObject child = NGUITools.AddChild(gameObject, ddo.prefab);
Transform trans = child.transform;
trans.position = UICamera.lastHit.point;
if (rotatePlacedObject) trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f);
Destroy(go);
}
}
}
I don't normally use C# and know nothing of it's little peculiarities. Don't quite understand why this is not showing though, should be straightforward. Am I missing something? Any assistance would be greatly appreciated.
Answer by sicga123 · Feb 23, 2013 at 04:50 PM
Yes. The bool was there originally and appears fine. I thought it might have problems to do with the parsing because there were a couple of errors in other scripts, but deleting those scripts changed nothing. The public string fails to appear.
Answer by doguhan · Jan 30, 2015 at 08:49 AM
NGUI uses [CustomEditor()] attribute to override default inspector behaviour. You have to find the corresponding file that defines 's editor behaviour and add your newly defined variable there too.