private void RenderSetPrefabOffsetFromObjectSurfaceInActiveCategoryButton() { if (GUILayout.Button(GetContentForSetPrefabOffsetFromObjectSurfaceInActiveCategoryButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth + 3.0f))) { PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory; UndoEx.RecordForToolAction(activePrefabCategory.GetAllPrefabs()); PrefabCategoryActions.SetPrefabOffsetFromObjectSurface(activePrefabCategory, ViewData.PrefabOffsetFromObjectSurface); } }
public static void SetPrefabOffsetFromGridSurface(PrefabCategory prefabCategory, float offsetFromGridSurface) { List <Prefab> allPrefabsInCategory = prefabCategory.GetAllPrefabs(); foreach (Prefab prefab in allPrefabsInCategory) { prefab.OffsetFromGridSurface = offsetFromGridSurface; } }
public void LoadAllPrefabsInActiveCategory() { PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory; if (activePrefabCategory != null) { List <Prefab> allPrefabsInCatgory = activePrefabCategory.GetAllPrefabs(); foreach (var prefab in allPrefabsInCatgory) { if (GetElementWithPrefab(prefab) == null) { var element = CreateNewElement(); element.Prefab = prefab; } } } }
private static void WritePrefabCategory(XmlTextWriter xmlWriter, PrefabCategory prefabCategory) { xmlWriter.WriteNewLine(2); xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabCategoryNode); xmlWriter.WriteNewLine(3); xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabCategoryNameNode); xmlWriter.WriteString(prefabCategory.Name); xmlWriter.WriteEndElement(); if (prefabCategory.ObjectGroup != null && prefabCategory.ObjectGroup.GroupObject != null) { xmlWriter.WriteNewLine(3); xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabCategoryAssociatedObjectGroupNameNode); xmlWriter.WriteString(prefabCategory.ObjectGroup.GroupObject.name); xmlWriter.WriteEndElement(); } List <string> pathFolderNames = prefabCategory.PathFolderNames; if (pathFolderNames != null && pathFolderNames.Count != 0) { xmlWriter.WriteNewLine(3); xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabCategoryFolderNamesParentNode); for (int folderNameIndex = 0; folderNameIndex < pathFolderNames.Count; ++folderNameIndex) { string folderName = pathFolderNames[folderNameIndex]; xmlWriter.WriteNewLine(4); xmlWriter.WriteStartElement(PrefabConfigXMLInfo.PrefabCategoryFolderNameNode + folderNameIndex.ToString()); xmlWriter.WriteString(folderName); xmlWriter.WriteEndElement(); } xmlWriter.WriteNewLine(3); xmlWriter.WriteEndElement(); } List <Prefab> allPrefabs = prefabCategory.GetAllPrefabs(); foreach (var prefab in allPrefabs) { WritePrefab(xmlWriter, prefab); } xmlWriter.WriteNewLine(2); xmlWriter.WriteEndElement(); }