Exemple #1
0
        public bool UpdateLinkState(bool checkFileChanged)
        {
            PrefabLinkState lastState = this.linkState;

            ComponentNode  cmpNode = this as ComponentNode;
            GameObjectNode objNode = (cmpNode != null ? cmpNode.Parent : this) as GameObjectNode;

            PrefabLink prefabLink           = objNode != null ? objNode.Obj.AffectedByPrefabLink : null;
            bool       affectedByPrefabLink = prefabLink != null;

            if (cmpNode != null)
            {
                affectedByPrefabLink = affectedByPrefabLink && prefabLink.AffectsObject(cmpNode.Component);
            }
            if (objNode != null)
            {
                affectedByPrefabLink = affectedByPrefabLink && prefabLink.AffectsObject(objNode.Obj);
            }

            string filePath   = affectedByPrefabLink ? prefabLink.Prefab.Path : null;
            bool   fileExists = this.linkLastExisted;

            if (checkFileChanged || this.linkLastPath != filePath)
            {
                fileExists = File.Exists(filePath);
            }

            // Prefab-linked entities
            if (affectedByPrefabLink && fileExists)             //prefabLink.Prefab.IsAvailable) // Not sufficient - might be loaded but with a broken path
            {
                this.linkState = PrefabLinkState.Active;
            }
            else if (cmpNode == null && objNode.Obj.PrefabLink != null)
            {
                this.linkState = PrefabLinkState.Broken;
            }
            else
            {
                this.linkState = PrefabLinkState.None;
            }

            this.linkLastExisted = fileExists;
            this.linkLastPath    = filePath;
            return(this.linkState != lastState);
        }
Exemple #2
0
 protected GameObjectNode ScanGameObject(GameObject obj, bool scanChildren)
 {
     if (obj == null) return null;
     GameObjectNode thisNode = new GameObjectNode(obj, !this.buttonShowComponents.Checked);
     foreach (Component c in obj.GetComponents<Component>())
     {
         ComponentNode compNode = this.ScanComponent(c);
         if (compNode != null) this.InsertNodeSorted(compNode, thisNode);
     }
     if (scanChildren)
     {
         foreach (GameObject c in obj.Children)
         {
             GameObjectNode childNode = this.ScanGameObject(c, scanChildren);
             if (childNode != null) this.InsertNodeSorted(childNode, thisNode);
         }
     }
     return thisNode;
 }