private static void CreateBrush(Brush.Type type) { if (!defaultMat) { MeshRenderer mr = GameObject.CreatePrimitive(PrimitiveType.Cube).GetComponent <MeshRenderer>(); defaultMat = mr.sharedMaterial; Object.DestroyImmediate(mr.gameObject); } GameObject brushGeom = GameObject.Find("BrushGeometry"); if (!brushGeom) { brushGeom = new GameObject("BrushGeometry"); brushGeom.isStatic = true; } GameObject brushObj = new GameObject(type + " Brush"); brushObj.isStatic = true; brushObj.transform.parent = brushGeom.transform; Brush brush = brushObj.AddComponent <Brush>(); brush.type = type; brush.GetComponent <MeshRenderer>().sharedMaterial = defaultMat; Selection.activeGameObject = brushObj; }
private static void CreateBrush(Brush.Type type) { GameObject brushGeom = GameObject.Find("BrushGeometry"); if (!brushGeom) { brushGeom = new GameObject("BrushGeometry"); brushGeom.isStatic = true; } GameObject brushObj = new GameObject(type + " Brush"); brushObj.isStatic = true; brushObj.transform.parent = brushGeom.transform; Brush brush = brushObj.AddComponent <Brush>(); brush.type = type; brush.GetComponent <MeshRenderer>().sharedMaterial = defaultMat; Selection.activeGameObject = brushObj; }