public static QuickPolygon Create(string name, MeshType meshIndex, Vector3 position, Quaternion rotation, bool isUI) { GameObject polygon = new GameObject(); if (!string.IsNullOrEmpty(name)) { polygon.name = name; } else { polygon.name = meshIndex.ToString(); } polygon.transform.position = position; polygon.transform.rotation = rotation; #if UNITY_EDITOR if (!Application.isPlaying) { Undo.RegisterCreatedObjectUndo(polygon, "Shape Created"); Selection.activeObject = polygon; } #endif QuickPolygon newPolygon = polygon.AddComponent <QuickPolygon>(); newPolygon.ShapeMeshIndex = meshIndex; newPolygon.IsUI = isUI; newPolygon.Reset(); newPolygon.RecalculateMesh(); return(newPolygon); }
public static QuickPolygon CreateFromLastPreset(string name, MeshType meshIndex, Vector3 position, Quaternion rotation, bool isUI) { PresetsRecord lastPreset = PresetsManager.GetLastUsedPreset(); QuickPolygon mesh = Create(name, meshIndex, position, rotation, isUI); if (lastPreset != null && PresetsManager.IsPresetExists(lastPreset)) { PresetsManager.LoadPresetFor(lastPreset, mesh); } else { Debug.LogWarning(MSG.Warnings.PRESET_LAST_NOT_FOUND); } mesh.RecalculateMesh(); return(mesh); }
private void RefreshTargets() { if (serializedObject.targetObject != null) { serializedObject.ApplyModifiedProperties(); for (int i = 0; i < targets.Length; i++) { QuickPolygon shape = (QuickPolygon)targets[i]; if (shape != null) { if (PrefabUtility.GetPrefabParent(shape.gameObject) != null || PrefabUtility.GetPrefabObject(shape.gameObject) == null) { shape.UpdateTransformType(); shape.RecalculateMesh(); } EditorUtility.SetDirty(shape); } } } }