Ejemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var player   = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(property.serializedObject.targetObject, property);
            var sObject  = property.serializedObject;
            var sEntries = property.FindPropertyRelative("entries");

            DrawPlay(position, sObject);

            color   = GUI.color; position.height = height;
            title   = label.text;
            tooltip = label.tooltip;

            for (var i = 0; i < sEntries.arraySize; i++)
            {
                var entry    = player.Entries[i];
                var sEntry   = sEntries.GetArrayElementAtIndex(i);
                var sRoot    = sEntry.FindPropertyRelative("root");
                var sSpeed   = sEntry.FindPropertyRelative("speed");
                var sAliases = sEntry.FindPropertyRelative("aliases");
                var rectL    = position; rectL.width = EditorGUIUtility.labelWidth - 16.0f;
                var rectR    = position; rectR.xMin += EditorGUIUtility.labelWidth;

                if (Event.current.isMouse == true && Event.current.button == 1 && rectL.Contains(Event.current.mousePosition) == true)
                {
                    Event.current.Use();
                    ShowMenu(sObject, sEntries, i, sRoot, sSpeed, title);
                }

                EditorGUI.PropertyField(position, sRoot, new GUIContent(title, tooltip)); position.y += heightStep;
                EditorGUI.indentLevel++;
                if (sSpeed.floatValue >= 0.0f)
                {
                    EditorGUI.PropertyField(position, sSpeed); position.y += heightStep;
                }

                for (var j = 0; j < sAliases.arraySize; j++)
                {
                    var alias  = entry.Aliases[j];
                    var sAlias = sAliases.GetArrayElementAtIndex(j);
                    var sKey   = sAlias.FindPropertyRelative("Key");
                    var sObj   = sAlias.FindPropertyRelative("Obj");

                    EditorGUI.BeginChangeCheck();

                    EditorGUI.showMixedValue = sObj.hasMultipleDifferentValues;
                    var obj = EditorGUI.ObjectField(position, new GUIContent(sKey.stringValue, ""), alias.Obj, alias.Type, true); position.y += heightStep;
                    EditorGUI.showMixedValue = false;

                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        sObj.objectReferenceValue = obj;
                    }
                }
                EditorGUI.indentLevel--;
            }

            GUI.color = color;
        }
Ejemplo n.º 2
0
        private void DrawAliases(Rect position, SerializedObject sObject, SerializedProperty property)
        {
            var sAliases   = property.FindPropertyRelative("aliases");
            var sTargets   = property.FindPropertyRelative("targets");
            var aliasCount = System.Math.Min(sAliases.arraySize, sTargets.arraySize);
            var aliasTypes = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(sObject.targetObject, property).Types;

            for (var i = 0; i < aliasCount; i++)
            {
                DrawAliasTarget(position, sAliases.GetArrayElementAtIndex(i), sTargets.GetArrayElementAtIndex(i), aliasTypes[i]); position.y += height;
            }
        }
Ejemplo n.º 3
0
        private void ValidateAndUpdate(SerializedObject sObject, SerializedProperty sPlayer)
        {
            sObject.ApplyModifiedProperties();

            foreach (var targetObject in sObject.targetObjects)
            {
                var player = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(targetObject, sPlayer);

                if (player != null)
                {
                    player.Validate(true);
                }
            }

            sObject.Update();
        }
Ejemplo n.º 4
0
        private void Validate(SerializedProperty property)
        {
            property.serializedObject.ApplyModifiedProperties();

            var sRoots = property.FindPropertyRelative("roots");

            if (sRoots.arraySize == 0)
            {
                sRoots.arraySize = 1; sRoots.serializedObject.ApplyModifiedProperties();
            }

            foreach (var targetObject in property.serializedObject.targetObjects)
            {
                var transitions = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(targetObject, property);

                transitions.Rebuild();
            }

            property.serializedObject.Update();
        }