Пример #1
0
        public bool Run(GameObject go)
        {
            var e = EventFactory.Get(TypeName);

            if (e != null)
            {
                if (UnityEngine.Application.isPlaying)
                {
                    e.Run(this, go);
                }
                else
                {
                    #if UNITY_EDITOR
                    e.RunEditor(this, go);
                    #endif
                }
                return(true);
            }

            throw new System.Exception($"Unhandled Type \"{TypeName}\"");
        }
Пример #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.MaxWidth(10000));

            EventBase eventbase = null;

            {
                EditorGUI.BeginChangeCheck();
                var type     = property.FindPropertyRelative("TypeName").stringValue;
                var selected = EditorGUILayout.Popup(Array.IndexOf(EventFactory.Identifiers, type), EventFactory.DisplayNames);

                if (selected >= 0)
                {
                    eventbase = EventFactory.Get(EventFactory.Identifiers[selected]);

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (eventbase != null)
                        {
                            property.FindPropertyRelative("TypeName").stringValue = eventbase.Identifier;
                        }
                    }
                }
            }

            EditorGUILayout.Space();

            if (eventbase != null)
            {
                EditorGUI.indentLevel++;
                eventbase.Property = property;
                eventbase.Inspector();
                eventbase.Property = null;
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndVertical();

            property.serializedObject.ApplyModifiedProperties();
        }