Quantcast
Channel: Questions in topic: "editing"
Viewing all articles
Browse latest Browse all 111

Multi Object Editing

$
0
0
I am creating a custom script editor where I wish to be able to edit multiple objects. The key points as I understand them are: -the [CanEditMultipleObjects] attribute is obviously required -I need to use a serialised property for each variable I wish to be able to edit on a multiple basis (I think) I'm a little unsure of exactly how serialised properties work, only that they do. -I am obtaining the serialised object from all targets OnEnable, and then finding the relevant properties for each property from this object. - I need to use serialisedObject.Update() and .ApplyModifiedProperties() at the beginning and end of my OnInspectorGUI. My queries are: In all examples, properties are assigned in a way similar to this: EditorGUILayout.IntSlider(MyPropertyX, 0, 100); Now without actually using MyPropertyX = before this statement, I am unsure as to how this is assigning the value to MyPropertyX. On top of this whenever I try to do: EditorGUILayout.Toggle("My bool toggle", MyPropertyY); The console throws an error stating that I need to use a bool, so properties can't simply used as bools? Meaning I am currently doing this. MyPropertyY.boolValue = EditorGUILayout.Toggle("My bool toggle", MyPropertyY.boolValue); Without specifically assigning the value with the "=" then the value isn't changed when editing, this inconsistency between how the properties is assigned is confusing me somewhat. Also as a last point, how do I achieve the same result as Unity's own multiple object editing where inconsistent values across multiple objects are represented by a dash "-" but I have no idea how this is achieved.

Viewing all articles
Browse latest Browse all 111

Trending Articles