Example #1
0
 private void OnValidate()
 {
     if (this.actionsList == null)
     {
         this.actionsList = gameObject.AddComponent <IActionsList>();
     }
 }
Example #2
0
        private void OnEnable()
        {
            if (this.actionsList == null)
            {
                this.actionsList = gameObject.AddComponent <IActionsList>();
            }

            #if UNITY_EDITOR
            if (this.actionsList.gameObject != this.gameObject)
            {
                IActionsList newActionsList = gameObject.AddComponent <IActionsList>();
                EditorUtility.CopySerialized(this.actionsList, newActionsList);

                SerializedObject serializedObject = new SerializedObject(this);
                serializedObject.FindProperty("actionsList").objectReferenceValue = newActionsList;
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
            #endif
        }
        // INITIALIZERS: -----------------------------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            this.forceInitialize = true;

            this.instance         = (IActionsList)target;
            this.spActions        = serializedObject.FindProperty(PROP_ACTIONS);
            this.spExecutingIndex = serializedObject.FindProperty(PROP_EXECI);

            this.UpdateSubEditors(instance.actions);
            this.editorSortableList = new EditorSortableList();

            if (this.target != null)
            {
                this.target.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
            }
        }
Example #4
0
        private IAction PickRandom(IActionsList list)
        {
            int idx = Random.Range(0, list.actions.Length);

            return(idx > -1 ? list.actions[idx] : null);
        }