New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Showing game object name instead of script name for script member variable in inspector #27
Comments
Hey check (this)[https://github.com//issues/24] The way It worked it was like vexe suggested: Override theToString method. Hope it helps! |
Thanks. I took your advice and gave this a try but without success:
What am I missing? |
I'm not sure, but I think ForceBasedLocomotion should be a system object in order to work. Anyways you should wait if Vexe replies. Im still a noob at this. |
Hey colms, unfortunately this is a Unity thing, if you use ObjectField on any non-null unity object, it will just display its name. In the case of Components (thus behaviours) the name property resolves to the gameObject name the component's attached to. But if you use PropertyField and have a serializedProperty wrapping your component field, it will show "GameObjectName (BehaviourType)" (via the internal property.objectReferenceStringValue) which is what you want I suppose. Since I don't deal with serializedProperties I use ObjectField, thus you get this useless display. I'm gonna try and see how to hack my way in. Worst case I could just use the field style I used on System.Objects, gives you total control over the display text, with a custom picker and all that. I would rather not to though but we'll see. |
An alternative solution is to include the type name in the label text and use FormatMethod like peladovii suggested, does this work for you?
OK I'm hardcoding "Behaviour" here but I'm just trying to see if this style of display works for you or not. I could for instance pass in the MemberInfo of 'behaviour' so you'd get reusable formatting applied on any UnityEngine.Object, i.e:
|
Thank you very much :) |
I have a monster called "AngelBaby" (don't ask). He has a script attached called "PouterChaseState" which causes the monster to chase the player character. The "PouterChaseState" does this using a Propulsion subtype, in this case, "ForceBasedPropulsion". I dragged the attached "ForceBasedPropulsion" into the Propulsion slot for the "PouterChaseState" but rather than saying the name of the script ("ForceBasedPropulsion") in that slot as I expected, it says the name of the game object ("AngelBaby").
Screenshot highlighted relevant parts:
http://i.imgur.com/hrct0sP.png
Is this a design decision or a bug? I'm treating it as a bug because I'm about to start working on a script that will have a list of Propulsion types and I now won't be able to know which is which in the list because they'll all have the same name after I've dragged them in (in this case "AngelBaby").
The text was updated successfully, but these errors were encountered: