private object OnNewPolyShape(object arg) { GameObject go; ExposeToEditor exposeToEditor; CreateNewShape(PBShapeType.Cube, out go, out exposeToEditor); go.name = "Poly Shape"; IRuntimeEditor rte = IOC.Resolve <IRuntimeEditor>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); Vector3 position; Quaternion rotation; GetPositionAndRotation(scene, out position, out rotation); go.transform.position = position; go.transform.rotation = rotation; PBMesh pbMesh = go.GetComponent <PBMesh>(); pbMesh.Clear(); PBPolyShape polyShape = go.AddComponent <PBPolyShape>(); polyShape.IsEditing = true; Editor.Undo.BeginRecord(); Editor.Selection.activeGameObject = go; m_proBuilderTool.Mode = ProBuilderToolMode.PolyShape; Editor.Undo.RegisterCreatedObjects(new[] { exposeToEditor }); Editor.Undo.EndRecord(); return(go); }
private void CreateNewShape(PBShapeType type, out GameObject go, out ExposeToEditor exposeToEditor) { go = PBShapeGenerator.CreateShape(type); go.AddComponent <PBMesh>(); Renderer renderer = go.GetComponent <Renderer>(); if (renderer != null && renderer.sharedMaterials.Length == 1 && renderer.sharedMaterials[0] == PBBuiltinMaterials.DefaultMaterial) { IMaterialPaletteManager paletteManager = IOC.Resolve <IMaterialPaletteManager>(); if (paletteManager.Palette.Materials.Count > 0) { renderer.sharedMaterial = paletteManager.Palette.Materials[0]; } } IRuntimeEditor rte = IOC.Resolve <IRuntimeEditor>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); Vector3 position; Quaternion rotation; GetPositionAndRotation(scene, out position, out rotation); exposeToEditor = go.AddComponent <ExposeToEditor>(); go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y; go.transform.rotation = rotation; }
private object OnNewShape(object arg) { GameObject go; ExposeToEditor exposeToEditor; CreateNewShape((PBShapeType)arg, out go, out exposeToEditor); IRuntimeEditor rte = IOC.Resolve <IRuntimeEditor>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); IRuntimeSelectionComponent selectionComponent = null; if (scene != null) { selectionComponent = scene.IOCContainer.Resolve <IRuntimeSelectionComponent>(); } Editor.Undo.BeginRecord(); if (selectionComponent == null || selectionComponent.CanSelect) { Editor.Selection.activeGameObject = go; } Editor.Undo.RegisterCreatedObjects(new[] { exposeToEditor }); Editor.Undo.EndRecord(); return(go); }
private object OnNewShape(object arg) { GameObject go = PBShapeGenerator.CreateShape((PBShapeType)arg); go.AddComponent <PBMesh>(); Renderer renderer = go.GetComponent <Renderer>(); if (renderer != null && renderer.sharedMaterials.Length == 1 && renderer.sharedMaterials[0] == PBBuiltinMaterials.DefaultMaterial) { IMaterialPaletteManager paletteManager = IOC.Resolve <IMaterialPaletteManager>(); if (paletteManager.Palette.Materials.Count > 0) { renderer.sharedMaterial = paletteManager.Palette.Materials[0]; } } IRuntimeEditor rte = IOC.Resolve <IRuntimeEditor>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); Vector3 position; Quaternion rotation; GetPositionAndRotation(scene, out position, out rotation); ExposeToEditor exposeToEditor = go.AddComponent <ExposeToEditor>(); go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y; go.transform.rotation = rotation; Editor.Undo.BeginRecord(); Editor.Selection.activeGameObject = go; Editor.Undo.RegisterCreatedObjects(new[] { exposeToEditor }); Editor.Undo.EndRecord(); return(go); }
private IScenePivot GetScenePivot() { if (m_editor.ActiveWindow != null) { IScenePivot scenePivot = m_editor.ActiveWindow.IOCContainer.Resolve <IScenePivot>(); if (scenePivot != null) { return(scenePivot); } } RuntimeWindow sceneWindow = m_editor.GetWindow(RuntimeWindowType.Scene); if (sceneWindow != null) { IScenePivot scenePivot = sceneWindow.IOCContainer.Resolve <IScenePivot>(); if (scenePivot != null) { return(scenePivot); } } return(null); }