private void Reset()
        {
            SerializedProperty spReferences = null;

            for (int i = 0; i < this.references.Length; ++i)
            {
                MBVariable reference = this.references[i];
                if (reference != null && reference.gameObject != this.gameObject)
                {
                    MBVariable newVariable = gameObject.AddComponent <MBVariable>();
                    EditorUtility.CopySerialized(reference, newVariable);

                    if (spReferences == null)
                    {
                        SerializedObject serializedObject = new SerializedObject(this);
                        spReferences = serializedObject.FindProperty("references");
                    }

                    spReferences.GetArrayElementAtIndex(i).objectReferenceValue = newVariable;
                }
            }

            if (spReferences != null)
            {
                spReferences.serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
        }
Exemplo n.º 2
0
        protected override void AfterPaintSubEditorsList()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("+", GUILayout.Height(20), GUILayout.Width(100)))
            {
                string     variableName = Guid.NewGuid().ToString("N");
                MBVariable variable     = this.CreateVariable(variableName);

                variable.variable.type = this.spType.intValue;
                Event.current.Use();
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }