void InitialEmpties() { // get geo mesh mesh = GetComponent <MeshFilter> ().mesh; //get geo GeoBehavior geo = GetComponent <GeoBehavior> (); // initialize empties empties = new GameObject[mesh.vertices.Length]; // create empty game objects to keep track of all vertices for (int i = 0; i < mesh.vertices.Length; i++) { Vector3 vertice = transform.TransformPoint(mesh.vertices [i]); GameObject emptyOb = new GameObject(); emptyOb.transform.position = vertice; emptyOb.transform.parent = transform; CubeProp cp = emptyOb.AddComponent <CubeProp> (); cp.controller = geo; empties [i] = emptyOb; } }
void OnGUI() { if (curViewState == -1) { GUI.DrawTexture(new Rect(0, 0, Screen.height / 2, Screen.height / 2), frontView); GUI.DrawTexture(new Rect(Screen.height / 2, 0, Screen.height / 2, Screen.height / 2), rightView); GUI.DrawTexture(new Rect(0, Screen.height / 2, Screen.height / 2, Screen.height / 2), topView); GUI.DrawTexture(new Rect(Screen.height / 2, Screen.height / 2, Screen.height / 2, Screen.height / 2), perspectiveView); GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), wirframe); GUI.Label(new Rect(0, 0, Screen.height / 2, Screen.height / 2), "Front View", viewLabelStyle); GUI.Label(new Rect(Screen.height / 2, 0, Screen.height / 2, Screen.height / 2), "Right View", viewLabelStyle); GUI.Label(new Rect(0, Screen.height / 2, Screen.height / 2, Screen.height / 2), "Top View", viewLabelStyle); GUI.Label(new Rect(Screen.height / 2, Screen.height / 2, Screen.height / 2, Screen.height / 2), "Perspective View", viewLabelStyle); if (curViewSelected == 0) { GUI.DrawTexture(new Rect(0, 0, Screen.height / 2, Screen.height / 2), seletedTexture); } else if (curViewSelected == 1) { GUI.DrawTexture(new Rect(0, Screen.height / 2, Screen.height / 2, Screen.height / 2), seletedTexture); } else if (curViewSelected == 2) { GUI.DrawTexture(new Rect(Screen.height / 2, 0, Screen.height / 2, Screen.height / 2), seletedTexture); } else if (curViewSelected == 3) { GUI.DrawTexture(new Rect(Screen.height / 2, Screen.height / 2, Screen.height / 2, Screen.height / 2), seletedTexture); } } else if (curViewState == 0) { GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), frontView); GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), wirframeOne); GUI.Label(new Rect(0, 0, Screen.height, Screen.height), "Front View", viewLabelStyle); } else if (curViewState == 1) { GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), topView); GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), wirframeOne); GUI.Label(new Rect(0, 0, Screen.height, Screen.height), "Top View", viewLabelStyle); } else if (curViewState == 2) { GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), rightView); GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), wirframeOne); GUI.Label(new Rect(0, 0, Screen.height, Screen.height), "Right View", viewLabelStyle); } else if (curViewState == 3) { GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), perspectiveView); GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.height), wirframeOne); GUI.Label(new Rect(0, 0, Screen.height, Screen.height), "Perspective View", viewLabelStyle); } GUILayout.BeginArea(new Rect(Screen.height, 0, Screen.width - Screen.height, Screen.height)); scrollPos = GUILayout.BeginScrollView(scrollPos, true, false, GUILayout.Width(Screen.width - Screen.height), GUILayout.Height(300)); foreach (GameObject cube in GameObject.FindGameObjectsWithTag("BaseModel")) { if (cube.GetComponent <MeshRenderer>().material.color.a == 0.7f && curObject != cube) { Color color = cube.GetComponent <MeshRenderer>().material.color; color.a = 1.0f; cube.GetComponent <MeshRenderer>().material.color = color; } if (GUILayout.Button(cube.name, GUILayout.Width(Screen.width - Screen.height - (Screen.width - Screen.height) / 10))) { curObject = cube; } } GUILayout.EndScrollView(); if (curObject != null) { transPosObj.transform.position = curObject.transform.position; transPosObj.SetActive(true); Color color = curObject.GetComponent <MeshRenderer>().material.color; color.a = 0.7f; curObject.GetComponent <MeshRenderer>().material.color = color; CubeProp cubeProp = curObject.GetComponent <CubeProp>(); GUILayout.Label("Position:"); GUILayout.BeginHorizontal(); GUILayout.Label("X:"); if (cubeProp.xPos.ToString() != "") { cubeProp.xPos = float.Parse(GUILayout.TextField(cubeProp.xPos.ToString())); } GUILayout.Label("Y:"); if (cubeProp.yPos.ToString() != "") { cubeProp.yPos = float.Parse(GUILayout.TextField(cubeProp.yPos.ToString())); } GUILayout.Label("Z:"); if (cubeProp.zPos.ToString() != "") { cubeProp.zPos = float.Parse(GUILayout.TextField(cubeProp.zPos.ToString())); } GUILayout.EndHorizontal(); if (curObject.transform.position != new Vector3(cubeProp.xPos, cubeProp.yPos, cubeProp.zPos)) { curObject.transform.position = new Vector3(cubeProp.xPos, cubeProp.yPos, cubeProp.zPos); } GUILayout.Label("Rotation:"); GUILayout.BeginHorizontal(); GUILayout.Label("X:"); if (cubeProp.xRot.ToString() != "") { GUILayout.BeginVertical(); cubeProp.xRot = float.Parse(GUILayout.TextField(cubeProp.xRot.ToString("000.000"))); cubeProp.xRot = GUILayout.HorizontalSlider(cubeProp.xRot, 0, 360); GUILayout.EndVertical(); } GUILayout.Label("Y:"); if (cubeProp.yRot.ToString() != "") { GUILayout.BeginVertical(); cubeProp.yRot = float.Parse(GUILayout.TextField(cubeProp.yRot.ToString("000.000"))); cubeProp.yRot = GUILayout.HorizontalSlider(cubeProp.yRot, 0, 360); GUILayout.EndVertical(); } GUILayout.Label("Z:"); if (cubeProp.zRot.ToString() != "") { GUILayout.BeginVertical(); cubeProp.zRot = float.Parse(GUILayout.TextField(cubeProp.zRot.ToString("000.000"))); cubeProp.zRot = GUILayout.HorizontalSlider(cubeProp.zRot, 0, 360); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (curObject.transform.rotation.eulerAngles != new Vector3(cubeProp.xRot, cubeProp.yRot, cubeProp.zRot)) { curObject.transform.rotation = Quaternion.Euler(cubeProp.xRot, cubeProp.yRot, cubeProp.zRot); } GUILayout.Label("Scale:"); GUILayout.BeginHorizontal(); GUILayout.Label("X:"); if (cubeProp.xScale.ToString() != "") { cubeProp.xScale = float.Parse(GUILayout.TextField(cubeProp.xScale.ToString())); } GUILayout.Label("Y:"); if (cubeProp.yScale.ToString() != "") { cubeProp.yScale = float.Parse(GUILayout.TextField(cubeProp.yScale.ToString())); } GUILayout.Label("Z:"); if (cubeProp.zScale.ToString() != "") { cubeProp.zScale = float.Parse(GUILayout.TextField(cubeProp.zScale.ToString())); } GUILayout.EndHorizontal(); if (curObject.transform.localScale != new Vector3(cubeProp.xScale, cubeProp.yScale, cubeProp.zScale)) { curObject.transform.localScale = new Vector3(cubeProp.xScale, cubeProp.yScale, cubeProp.zScale); } } else { transPosObj.SetActive(false); } GUILayout.EndArea(); }