示例#1
0
        public void ScanTarget(GameObject target)
        {
            var  states        = Locate.GetObjectComponents <StateTable>(target).Cast <StateBehaviour>().ToArray();
            bool keepSearching = states.Length < 1 || states[0] == this;

            if (states.Contains(this) && states.Length == 1 || states.Length == 0)
            {
                states = Locate.GetObjectComponents <StateBehaviour>(target);
            }
            foreach (var state in states)
            {
                if (state.id.IsEmpty())
                {
                    state.id = state.GetInstanceID().ToString();
                }
                if (state != this)
                {
                    state.controller = this;
                }
                this.scripts.Add(state);
            }
            if (keepSearching)
            {
                foreach (var transform in target.transform)
                {
                    var current = transform.As <Component>().gameObject;
                    if (current != target)
                    {
                        this.ScanTarget(current);
                    }
                }
            }
        }
示例#2
0
 public void OnSelectionChange()
 {
     this.target     = Selection.activeGameObject;
     this.editor     = Editor.CreateEditor(this.target);
     this.components = this.target.IsNull() ? new Component[0] : Locate.GetObjectComponents <Component>(this.target).Where(x => !x.IsNull()).ToArray();
     this.editors    = this.components.Select(x => Editor.CreateEditor(x)).ToArray();
     this.dirty      = true;
     this.Repaint();
 }
示例#3
0
        public virtual void Awake()
        {
            string name = this.GetType().Name.ToTitleCase();

            this.parentPath = this.gameObject.GetPath();
            this.path       = this.GetPath();
            this.lastAlias  = this.alias = this.alias.SetDefault(name);
            if (this.autoRename)
            {
                while (Locate.GetObjectComponents <DataBehaviour>(this.gameObject).Exists(x => x != this && x.alias == this.alias))
                {
                    this.lastAlias = this.alias = this.alias.ToLetterSequence();
                }
            }
            if (!Application.isPlaying)
            {
                Events.Register("On Destroy", this);
                Events.Register("On Validate", this);
                Events.Add("On Validate", this.CheckDependents, this);
                Events.Add("On Validate", this.CheckAlias, this);
            }
        }
示例#4
0
 public static void CallChildren(object target, string name, object[] values, bool self = false)
 {
     if (Events.HasDisabled("Call"))
     {
         return;
     }
     if (self)
     {
         Events.Call(target, name, values);
     }
     if (target is GameObject)
     {
         var         gameObject = (GameObject)target;
         Transform[] children   = Locate.GetObjectComponents <Transform>(gameObject);
         foreach (Transform transform in children)
         {
             if (transform.gameObject == gameObject)
             {
                 continue;
             }
             Events.CallChildren(transform.gameObject, name, values, true);
         }
     }
 }