- Home /
Question by
Parchi · Nov 03, 2015 at 05:23 PM ·
serializedproperty
How does SerializedProperty iteration work?
I know about IEnumerator and how to iterate over a collection. However I can't figure out how does exaclty work the SerializedProperty iteration. For instance, I' ve made this script to for a custom inspector: using UnityEngine; using System.Collections; using UnityEditor;
[CustomEditor(typeof(PruebaScript))]
public class Prueba : Editor
{
SerializedProperty a;
SerializedProperty b;
SerializedProperty c;
SerializedProperty d;
SerializedProperty e;
void OnEnable()
{
if(a==null)
a = serializedObject.FindProperty ("a");
if(b==null)
b = serializedObject.FindProperty ("b");
if(c==null)
c = serializedObject.FindProperty ("c");
if(d==null)
d = serializedObject.FindProperty ("d");
if(e==null)
e = serializedObject.FindProperty ("e");
}
public override void OnInspectorGUI()
{
serializedObject.Update ();
a.floatValue = EditorGUILayout.Slider (a.floatValue, 0.0f, 100f);
b.floatValue = EditorGUILayout.Slider (b.floatValue, 0.0f, 100f);
c.floatValue = EditorGUILayout.Slider (c.floatValue, 0.0f, 100f);
d.floatValue = EditorGUILayout.Slider (d.floatValue, 0.0f, 100f);
e.floatValue = EditorGUILayout.Slider (e.floatValue, 0.0f, 100f);
if (GUILayout.Button ("DoSomethingWithIEnumerator"))
{
//
}
serializedObject.ApplyModifiedProperties ();
}
}
This script makes 4 sliders and one button in the "PruebaScript" inspector. However i've not made a list, dictionary , queue or any type of collection to iterate with. So that, how does exactly SerializedProperty's public functions such as Next,NextVisible or Reset work?
Comment
Your answer
