/// <summary> /// Creates a Blockout trigger in 10 units in front of the scene camera /// </summary> void CreateTrigger() { var target = Instantiate(m_triggerPrefab); Undo.RegisterCreatedObjectUndo(target, "Created Blockout Trigger"); target.transform.position = BlockoutStaticFunctions.GetSceneViewSpawnPosition(); target.transform.SetParent(blockoutHierarchy.triggers); target.name = m_triggerPrefab.name; Selection.activeGameObject = target; BlockoutStaticFunctions.SnapPositionSelection(); SceneView.lastActiveSceneView.FrameSelected(); }
/// <summary> /// Creates a tri planer asset in front of the camera. /// </summary> /// <param name="prefab">The target tri planar prefab</param> private void CreateTriPlanerAsset(GameObject prefab) { var target = Instantiate(prefab); Undo.RegisterCreatedObjectUndo(target, "Created Tri-Planer Asset"); target.transform.position = BlockoutStaticFunctions.GetSceneViewSpawnPosition(); target.name = prefab.name + " (Tri-Planar)"; Selection.activeGameObject = target; BlockoutStaticFunctions.SnapPositionSelection(); SceneView.lastActiveSceneView.FrameSelected(); Tools.current = Tool.Scale; BlockoutStaticFunctions.ApplyCurrentTheme(); }
public override void Update() { // Auto snapping position if (BlockoutEditorSettings.AutoSnap && !EditorApplication.isPlaying && Selection.transforms.Length > 0 && Selection.transforms[0].position != prevPosition) { if ((Selection.transforms[0].position - prevPosition).magnitude > snapValue) { prevPosition = Selection.transforms[0].position; previousObjectMain = currentObjectMain; currentObjectMain = Selection.transforms[0].gameObject; } else if (previousObjectMain != null) { BlockoutStaticFunctions.SnapPositionSelection(); prevPosition = Selection.transforms[0].position; } } // Auto snapping scale if (BlockoutEditorSettings.AutoSnap && !EditorApplication.isPlaying && Selection.transforms.Length > 0 && Selection.transforms[0].lossyScale != prevScale) { if ((Selection.transforms[0].lossyScale - prevScale).magnitude > snapValue) { prevScale = Selection.transforms[0].lossyScale; previousObjectMain = currentObjectMain; currentObjectMain = Selection.transforms[0].gameObject; } else if (previousObjectMain != null) { BlockoutStaticFunctions.SnapScaleSelection(); prevScale = Selection.transforms[0].lossyScale; } } }