public void Associate(string tagName)
        {
            PrefabTag prefabTagWithSpecifiedName = PrefabTagDatabase.Get().GetPrefabTagByName(tagName);

            if (prefabTagWithSpecifiedName != null)
            {
                _associatedTags.Add(prefabTagWithSpecifiedName);
            }
        }
        public void AssociateWithAllTagsInDatabase()
        {
            List <PrefabTag> allPrefabTags = PrefabTagDatabase.Get().GetAllPrefabTags();

            foreach (PrefabTag prefabTag in allPrefabTags)
            {
                Associate(prefabTag);
            }
        }
예제 #3
0
        private void RenderSelectAllTagsButton()
        {
            if (GUILayout.Button(GetContentForSelectAllTagsButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth)))
            {
                UndoEx.RecordForToolAction(ViewData);

                ViewData.ListOfSelectedTagNames = PrefabTagDatabase.Get().GetAllPrefabTagNames();
                ViewData.HasSelectionChanged    = true;
            }
        }
예제 #4
0
        private void RenderTagNameChangeField()
        {
            string newName = EditorGUILayoutEx.DelayedTextField(GetContentForTagNameChangeField(), _prefabTag.Name);

            if (newName != _prefabTag.Name)
            {
                UndoEx.RecordForToolAction(_prefabTag);
                PrefabTagDatabase.Get().RenamePrefabTag(_prefabTag, newName);
            }
        }
예제 #5
0
        protected override void RenderContent()
        {
            if (!PrefabTagDatabase.Get().IsEmpty)
            {
                _prefabTagDatabase.PrefabTagFilter.View.Render();
                RenderPrefabTagScrollView();
            }
            else
            {
                EditorGUILayoutEx.InformativeLabel("There are no prefab tags to display.");
            }

            RenderActionControls();
        }
예제 #6
0
        protected override void RenderContent()
        {
            if (!PrefabTagDatabase.Get().IsEmpty)
            {
                _prefabTagDatabase.PrefabTagFilter.View.Render();
                RenderPrefabTagScrollView();
            }
            else
            {
                EditorGUILayout.HelpBox("There are no prefab tags to display.", UnityEditor.MessageType.None);
            }

            RenderActionControls();
        }
        private void CreateTagsForDroppedFolderIfNecessaryAndAssociate(PrefabFolderDropData prefabFolderDropData)
        {
            string lastFolderNameInFoderPath = prefabFolderDropData.FolderNameInPath;

            if (PrefabTagDatabase.Get().ContainsPrefabTag(lastFolderNameInFoderPath))
            {
                PrefabActions.AssociatePrefabsWithTag(prefabFolderDropData.ValidPrefabs, lastFolderNameInFoderPath);
            }
            else
            {
                UndoEx.RecordForToolAction(PrefabTagDatabase.Get());
                PrefabTag prefabTag = PrefabTagDatabase.Get().CreatePrefabTag(lastFolderNameInFoderPath);
                PrefabActions.AssociatePrefabsWithTag(prefabFolderDropData.ValidPrefabs, prefabTag);
            }
        }
예제 #8
0
        private static void ReadAllPrefabTags(XmlNode prefabTagsDatabaseNode)
        {
            XmlNodeList prefabTagNodes = prefabTagsDatabaseNode.ChildNodes;

            if (prefabTagNodes.Count == 0)
            {
                return;
            }

            for (int tagNodeIndex = 0; tagNodeIndex < prefabTagNodes.Count; ++tagNodeIndex)
            {
                EditorUtility.DisplayProgressBar("Loading prefab tags...", "", (tagNodeIndex + 1) / (float)prefabTagNodes.Count);

                XmlNode tagNode     = prefabTagNodes[tagNodeIndex];
                XmlNode tagNameNode = tagNode.SelectSingleNode(PrefabConfigXMLInfo.PrefabTagNameNode);
                if (tagNameNode == null)
                {
                    continue;
                }
                XmlNode tagIsActiveNode = tagNode.SelectSingleNode(PrefabConfigXMLInfo.PrefabTagActiveNode);

                string prefabTagName = tagNameNode.InnerText;
                if (string.IsNullOrEmpty(prefabTagName))
                {
                    continue;
                }

                bool isTagActive = true;
                try
                {
                    if (tagIsActiveNode != null)
                    {
                        isTagActive = bool.Parse(tagIsActiveNode.InnerText);
                    }
                }
                catch (Exception) { }

                var prefabTag = PrefabTagDatabase.Get().CreatePrefabTag(prefabTagName);
                if (prefabTag == null)
                {
                    continue;
                }

                prefabTag.IsActive = isTagActive;
            }
            EditorUtility.ClearProgressBar();
        }
예제 #9
0
        private static void WritePrefabTagsDatabase(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteNewLine(1);
            xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabTagDatabaseNode);

            List <PrefabTag> allPrefabTags = PrefabTagDatabase.Get().GetAllPrefabTags();

            for (int tagIndex = 0; tagIndex < allPrefabTags.Count; ++tagIndex)
            {
                EditorUtility.DisplayProgressBar("Saving prefab tags...", "", (tagIndex + 1) / (float)allPrefabTags.Count);
                WritePrefabTag(xmlWriter, allPrefabTags[tagIndex]);
            }
            EditorUtility.ClearProgressBar();

            xmlWriter.WriteNewLine(1);
            xmlWriter.WriteEndElement();
        }
예제 #10
0
        public static void LoadConfig(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(fileName);

            UndoEx.RecordForToolAction(PrefabTagDatabase.Get());
            PrefabTagDatabase.Get().RemoveAndDestroyAllPrefabTags();
            XmlNodeList prefabTagsDatabaseNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabTagDatabaseNode);

            if (prefabTagsDatabaseNodes.Count != 0)
            {
                ReadAllPrefabTags(prefabTagsDatabaseNodes[0]);
            }

            UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get());
            PrefabCategoryDatabase.Get().RemoveAndDestroyAllPrefabCategories(true);
            XmlNodeList prefabCategoryDatabaseNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabCategoryDatabaseNode);

            if (prefabCategoryDatabaseNodes.Count != 0)
            {
                ReadAllPrefabCategories(prefabCategoryDatabaseNodes[0]);
            }

            PrefabPreviewTextureCache.Get().GeneratePreviewForAllPrefabCategories(true);

            PrefabCategory firstNonEmptyCategory = PrefabCategoryDatabase.Get().GetFirstNonEmptyCategory();

            if (firstNonEmptyCategory != null)
            {
                PrefabCategoryDatabase.Get().SetActivePrefabCategory(firstNonEmptyCategory);
            }

            XmlNodeList prefabScrollViewLookAndFeelNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabScrollViewLookAndFeelNode);

            if (prefabScrollViewLookAndFeelNodes.Count != 0)
            {
                ReadPrefabScrollViewLookAndFeel(prefabScrollViewLookAndFeelNodes[0]);
            }
        }
예제 #11
0
        protected override void RenderContent()
        {
            if (PrefabTagDatabase.Get().IsEmpty)
            {
                EditorGUILayoutEx.InformativeLabel("There are no prefab tags to display.");
            }
            else
            {
                AcquireFilteredPrefabTags();

                if (_prefabTagFilter != null)
                {
                    _prefabTagFilter.View.Render();
                }
                RenderPrefabTagSelectionScrollView();
                RenderSelectDeselectAllTagsButtons();
                RenderSelectDeselectOnlyFilteredTagsButtons();
            }
        }
예제 #12
0
        protected override void RenderContent()
        {
            if (PrefabTagDatabase.Get().IsEmpty)
            {
                EditorGUILayout.HelpBox("There are no prefab tags to display.", UnityEditor.MessageType.None);
            }
            else
            {
                AcquireFilteredPrefabTags();

                if (_prefabTagFilter != null)
                {
                    _prefabTagFilter.View.Render();
                }
                RenderPrefabTagSelectionScrollView();
                RenderSelectDeselectAllTagsButtons();
                RenderSelectDeselectOnlyFilteredTagsButtons();
            }
        }
예제 #13
0
        private void RemoveNullGameObjectReferences()
        {
            ObjectSelection.Get().RemoveNullGameObjectEntries();
            Octave3DWorldBuilder.ActiveInstance.PlacementObjectGroupDatabase.RemoveGroupsWithNullParents();
            ObjectSnapping.Get().ObjectSnapMask.RemoveInvalidEntries();
            DecorPaintObjectPlacement.Get().DecorPaintMask.RemoveInvalidEntries();

            if (PrefabTagDatabase.Get().ContainsNullEntries())
            {
                Debug.Log("Detected null prefab tag references. This bug has been fixed and should never happen. If you are reading this, please contact me.");

                List <PrefabCategory> allPrefabCategories = PrefabCategoryDatabase.Get().GetAllPrefabCategories();
                foreach (var category in allPrefabCategories)
                {
                    List <Prefab> allPrefabsInCategory = category.GetAllPrefabs();
                    foreach (var prefab in allPrefabsInCategory)
                    {
                        prefab.TagAssociations.RemoveNullEntries();
                    }
                }

                PrefabTagDatabase.Get().RemoveNullEntries();
            }
        }
예제 #14
0
 private void RenderContentInScrollView()
 {
     EditorGUILabelWidth.Push(EditorGUILayoutEx.PreferedEditorWindowLabelWidth);
     PrefabTagDatabase.Get().View.Render();
     EditorGUILabelWidth.Pop();
 }
예제 #15
0
        public bool IsAssociatedWith(string tagName)
        {
            PrefabTag prefabTagWithSpecifiedName = PrefabTagDatabase.Get().GetPrefabTagByName(tagName);

            return(_associatedTags.Contains(prefabTagWithSpecifiedName));
        }