private void LoadFromPrefab() { var reloadBrushInformation = true; if (!decorPrefab && decorMap.lastDecorPrefabUsed) { decorPrefab = decorMap.lastDecorPrefabUsed; reloadBrushInformation = false; } if (decorPrefab) { decorList.Clear(); decorMap.lastDecorPrefabUsed = decorPrefab; if (reloadBrushInformation && decorMap.brushInformationList.Count != 0) { decorMap.brushInformationList.Clear(); } foreach (Transform childTransform in decorPrefab.transform) { decorList.Add(childTransform.gameObject); if (reloadBrushInformation) { decorMap.brushInformationList.Add(new BrushInformation()); } } if (decorMap.brushInformationList.Count != 0) { brushInformation = decorMap.brushInformationList[0]; } currentDecor = decorList[0]; Repaint(); } }
private void SetValues() { if (decorMap.brushInformationList.Count >= currentDecorNumber && decorMap.brushInformationList.Count != 0) { brushInformation = decorMap.brushInformationList[currentDecorNumber]; } currentDecor = (GameObject)EditorGUILayout.ObjectField("Current decor", currentDecor, typeof(GameObject), false); decorPrefab = (GameObject)EditorGUILayout.ObjectField("Decor prefab", decorPrefab, typeof(GameObject), true); brushInformation.decorHeight = EditorGUILayout.FloatField("Decor Height", brushInformation.decorHeight); brushInformation.decorWidth = EditorGUILayout.FloatField("Decor Width", brushInformation.decorWidth); brushInformation.randomRotation = EditorGUILayout.Slider("Random Rotation", brushInformation.randomRotation, 0.0f, 180.0f); brushInformation.overrideDefaultDeleteBrush = EditorGUILayout.Toggle("Use custom delete brush", brushInformation.overrideDefaultDeleteBrush); if (brushInformation.overrideDefaultDeleteBrush) { brushInformation.deleteBrushHeight = EditorGUILayout.Slider("Delete Brush Height", brushInformation.deleteBrushHeight, 0.01f, 5.0f); brushInformation.deleteBrushWidth = EditorGUILayout.Slider("Delete Brush Width", brushInformation.deleteBrushWidth, 0.01f, 5.0f); brushInformation.deleteIterations = EditorGUILayout.FloatField("Iterations of delete brush", brushInformation.deleteIterations); } else { brushInformation.deleteBrushHeight = brushInformation.decorHeight; brushInformation.deleteBrushWidth = brushInformation.decorWidth; } }
private void GoToPreviousDecor() { try { if (currentDecorNumber != 0) { currentDecorNumber--; } else { currentDecorNumber = decorList.Count - 1; } brushInformation = decorMap.brushInformationList[currentDecorNumber]; currentDecor = decorList[currentDecorNumber]; Repaint(); } catch (Exception) { Debug.Log("Please assign a prefab with children decor objects."); } }