示例#1
0
        private void AcquireFilteredPrefabTags()
        {
            PrefabTagDatabase prefabTagDatabase = PrefabTagDatabase.Get();
            List <PrefabTag>  prefabTags        = prefabTagDatabase.GetAllPrefabTags();

            _filteredTags = _prefabTagFilter != null?_prefabTagFilter.GetFilteredPrefabTags(prefabTags) : prefabTags;
        }
示例#2
0
 private void RenderRemoveTagButton()
 {
     if (GUILayout.Button(GetContentForRemoveTagButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth)))
     {
         UndoEx.RecordForToolAction(PrefabTagDatabase.Get());
         PrefabTagDatabase.Get().RemoveAndDestroyPrefabTag(_prefabTag);
     }
 }
示例#3
0
        public void Associate(string tagName)
        {
            PrefabTag prefabTagWithSpecifiedName = PrefabTagDatabase.Get().GetPrefabTagByName(tagName);

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

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

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

            if (newName != _prefabTag.Name)
            {
                UndoEx.RecordForToolAction(_prefabTag);
                PrefabTagDatabase.Get().RenamePrefabTag(_prefabTag, newName);
            }
        }
示例#7
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();
        }
        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);
            }
        }
示例#10
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();
        }
示例#11
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();
        }
示例#12
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]);
            }
        }
示例#13
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();
            }
        }
示例#14
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();
            }
        }
示例#15
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();
            }
        }
示例#16
0
 private void RenderContentInScrollView()
 {
     EditorGUILabelWidth.Push(EditorGUILayoutEx.PreferedEditorWindowLabelWidth);
     PrefabTagDatabase.Get().View.Render();
     EditorGUILabelWidth.Pop();
 }
示例#17
0
        public bool IsAssociatedWith(string tagName)
        {
            PrefabTag prefabTagWithSpecifiedName = PrefabTagDatabase.Get().GetPrefabTagByName(tagName);

            return(_associatedTags.Contains(prefabTagWithSpecifiedName));
        }