static void UpdateLabels(PrettyPoly poly) { List <string> labels = new List <string>(AssetDatabase.GetLabels(poly.gameObject)); if (!labels.Contains("PrettyPoly")) { labels.Add("PrettyPoly"); } AssetDatabase.SetLabels(poly.gameObject, labels.ToArray()); }
static void CreatePrettyPoly() { Camera sceneCam = SceneView.lastActiveSceneView.camera; Vector3 spawnPos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f)); GameObject go = new GameObject("PrettyPoly"); go.transform.position = spawnPos; Selection.activeGameObject = go; PrettyPoly p = go.AddComponent <PrettyPoly>(); UpdateLabels(p); p.points = new PrettyPolyPoint[] { new PrettyPolyPoint(new Vector3(-1, -1, 0)), new PrettyPolyPoint(new Vector3(1, -1, 0)), new PrettyPolyPoint(new Vector3(0, 1, 0)) }; p.closed = true; Undo.RegisterCreatedObjectUndo(go, "Created PrettyPoly"); }
void OnGUI() { selectedPrefab = EditorGUILayout.Popup("PrettyPoly Prefab", selectedPrefab, prefabNames); if (prefab == null) { EditorGUILayout.HelpBox("Prefab required", MessageType.Info, true); if (isPainting) { StopPainting(); } return; } PrettyPoly prettyPoly = prefab.GetComponent <PrettyPoly>(); if (prettyPoly == null) { EditorGUILayout.HelpBox("PrettyPoly component required", MessageType.Warning, true); if (isPainting) { StopPainting(); } return; } overlapThreshold = EditorGUILayout.FloatField("Overlap Threshold", overlapThreshold); if (!isPainting) { if (GUILayout.Button("Paint")) { StartPainting(); } } else if (GUILayout.Button("Stop")) { StopPainting(); } }
static void UpdateLabels(PrettyPoly poly) { List<string> labels = new List<string>(AssetDatabase.GetLabels(poly.gameObject)); if (!labels.Contains("PrettyPoly")) labels.Add("PrettyPoly"); AssetDatabase.SetLabels(poly.gameObject, labels.ToArray()); }
static void Update() { Transform selection = Selection.activeTransform; if (selection == null || selection.parent == null) { selectedPoly = null; return; } PrettyPoly prettyPoly = selection.parent.gameObject.GetComponent<PrettyPoly>(); if (prettyPoly != null && selectedPoly != prettyPoly) { Selection.activeGameObject = prettyPoly.gameObject; selectedPoly = prettyPoly; } }