private void OnTargetSelected()
        {
            // If there's no target information or if the target is different from the previous
            //if (this.currentTargetInformation == null || this.currentTargetInformation.target != this.target)
            {
                // If the target has as bookmark, use that information instead
                StratusGameObjectBookmark bookmark = this.target.GetComponent <StratusGameObjectBookmark>();
                if (bookmark != null)
                {
                    this.informationMode          = InformationMode.Bookmark;
                    this.currentTargetInformation = bookmark.information;
                }
                // Otherwise recreate the current target information
                else if (this.currentTargetInformation == null || this.currentTargetInformation.target != this.target)
                {
                    this.informationMode            = InformationMode.Temporary;
                    this.targetTemporaryInformation = new StratusGameObjectInformation(this.target);
                    this.currentTargetInformation   = this.targetTemporaryInformation;
                }

                //Trace.Script($"Setting target information for {this.target.name}");
            }

            //this.showComponent = this.GenerateAnimBools(this.currentTargetInformation.numberofComponents, false);
            //this.componentList = new DropdownList<ComponentInformation>(this.currentTargetInformation.components, (ComponentInformation component) => component.name, this.lastComponentIndex);
            this.SetTreeView();
        }
 protected override void OnStratusEditorBehaviourEnable()
 {
     if (this._information == null)
     {
         this._information = new StratusGameObjectInformation(gameObject);
     }
     StratusGameObjectBookmark.UpdateAvailable();
 }
        //------------------------------------------------------------------------/
        // Methods: Target Selection
        //------------------------------------------------------------------------/
        private void SelectTarget()
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Target", StratusGUIStyles.header);
            bool changed = StratusEditorUtility.CheckControlChange(() =>
            {
                this.target = (GameObject)EditorGUILayout.ObjectField(this.target, this.gameObjectType, true);
                StratusEditorUtility.OnLastControlMouseClick(null, () =>
                {
                    bool hasBookmark     = this.target.HasComponent <StratusGameObjectBookmark>();
                    string bookmarkLabel = hasBookmark ? "Remove Bookmark" : "Bookmark";
                    GenericMenu menu     = new GenericMenu();

                    // 1. Bookmark
                    if (hasBookmark)
                    {
                        menu.AddItem(new GUIContent(bookmarkLabel), false, () =>
                        {
                            RemoveBookmark(target);
                        });
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(bookmarkLabel), false, () =>
                        {
                            SetBookmark(target);
                        });
                    }

                    // 2. Clear Favorites
                    menu.AddItem(new GUIContent("Clear Watch List"), false, () =>
                    {
                        this.currentTargetInformation.ClearWatchList();
                    });

                    menu.ShowAsContext();
                });
            });

            if (changed)
            {
                if (this.target)
                {
                    this.OnTargetSelected();
                }
                else
                {
                    this.currentTargetInformation = null;

                    if (this.informationMode == InformationMode.Temporary)
                    {
                        this.targetTemporaryInformation = null;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static List <MemberInspectorTreeElement> GenerateInspectorTree(StratusGameObjectInformation target)
        {
            var tree = new StratusSerializedTree <MemberInspectorTreeElement, StratusComponentInformation.MemberReference>();

            tree.AddElements(target.members, 0);
            return(tree.elements);
            //TreeBuilder<MemberInspectorTreeElement, ComponentInformation.MemberReference> treeBuilder = new TreeBuilder<MemberInspectorTreeElement, ComponentInformation.MemberReference>();
            //treeBuilder.AddChildren(target.members, 0);
            //return treeBuilder.ToTree();
        }
        public void SetInformation(StratusGameObjectInformation information)
        {
            if (information.target != this.gameObject)
            {
                return;
            }

            this._information = (StratusGameObjectInformation)information.CloneJSON();
            this._information.CacheReferences();
            StratusGameObjectBookmark.UpdateAvailable();
        }
 private void CheckTarget()
 {
     if (this.target)
     {
         this.OnTargetSelected();
     }
     else
     {
         this.currentTargetInformation = this.targetTemporaryInformation = null;
     }
 }
        private void OnGameObjectInformationChanged(StratusGameObjectInformation information, StratusGameObjectInformation.Change change)
        {
            //Trace.Script($"Information changed for {information.target.name}, change = {change}");

            if (change == StratusGameObjectInformation.Change.ComponentsAndWatchList)
            {
                StratusGameObjectBookmark.UpdateWatchList();
            }

            this.SetTreeView();
            //this.OnBookmarkUpdate();
        }
 //------------------------------------------------------------------------/
 // Messages
 //------------------------------------------------------------------------/
 protected override void OnReset()
 {
     this._information = new StratusGameObjectInformation(this.gameObject);
 }