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 static void CreateShape(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]; } } exposeToEditor = go.AddComponent <ExposeToEditor>(); }
private void OnCreatePrimitive() { PBShapeType type = PBShapeType.Stair; GameObject go; ExposeToEditor exposeToEditor; CreateShape(type, out go, out exposeToEditor); IRTE rte = IOC.Resolve <IRTE>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); Vector3 position; Quaternion rotation; GetPositionAndRotation(scene, out position, out rotation); go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y; go.transform.rotation = rotation; }
public static GameObject CreateShape(PBShapeType shapeType) { Material defaultMaterial; //try //{ // defaultMaterial = BuiltinMaterials.defaultMaterial; //} //catch //{ //} defaultMaterial = PBBuiltinMaterials.DefaultMaterial; GameObject shape = ShapeGenerator.CreateShape((ShapeType)shapeType, PivotLocation.Center).gameObject; Renderer renderer = shape.GetComponent <Renderer>(); renderer.sharedMaterial = defaultMaterial; return(shape); }
public static GameObject CreateShape(PBShapeType shapeType) { Material defaultMaterial; try { //ProBuilder throws exception form Init method line 106 (when trying to initialize preview material) defaultMaterial = BuiltinMaterials.defaultMaterial; } catch { } defaultMaterial = PBBuiltinMaterials.DefaultMaterial; GameObject shape = ShapeGenerator.CreateShape((ShapeType)shapeType, PivotLocation.Center).gameObject; Renderer renderer = shape.GetComponent <Renderer>(); renderer.sharedMaterial = defaultMaterial; return(shape); }
public static GameObject CreateShape(PBShapeType shapeType) { return(ShapeGenerator.CreateShape((ShapeType)shapeType, PivotLocation.Center).gameObject); }