public static void DrawHelper(GameObject obj) { if (_checktip == null) { _checktip = new GUIContent(string.Empty, "Check Multi be Same"); _multitip = new GUIContent(string.Empty, "Multi TreeTransform"); _subtip = new GUIContent(string.Empty, "Sub From TreeTransform"); _addtip = new GUIContent(string.Empty, "Add To TreeTransform"); } Rect rect = HierarchyHelperManager.GetControlRect(8f); rect.y += 3; rect.height -= 6; TreeTransform mine = obj.GetComponentInParent <TreeTransform>(); int num = 0; if (mine == null) { return; } else if (mine.gameObject == obj) { num = mine.CheckMulti(); HierarchyHelperTools.DrawWithColor(num == 2?Color.yellow:(num == 1?Color.red:Color.green), () => { GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true); GUI.Label(rect, _checktip); }); return; } num = mine.CheckChild(obj.transform); Color color = num == 0 ? Color.white : (num == 1 ? Color.green : Color.red); if (GUI.Button(rect, "", "label")) { if (num == 0) { mine.AddChild(obj.transform); } else { mine.SubChild(obj.transform); } } HierarchyHelperTools.DrawWithColor(color, () => { GUI.Label(rect, num == 0 ? _addtip : (num == 1 ? _subtip : _multitip)); rect.y += 4; rect.height -= 8; GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true); if (num == 0) { rect.y -= 4; rect.x += 3; rect.height += 8; rect.width -= 6; GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true); } }); }
public static Transform TreeFind(this Transform trans, string childName) { TreeTransform treeTrans = trans.GetComponent <TreeTransform>(); if (treeTrans == null) { return(null); } int index = childName.IndexOf('/'); if (index == -1) { return(treeTrans.FindChild(childName)); } string firstName = childName.Substring(0, index); string secName = childName.Substring(index + 1); Transform child = treeTrans.FindChild(firstName); return(child.TreeFind(secName)); }
// Use this for initialization void Start() { d = Dials.Instance; d.mult = 10; xForm2 = new TreeTransform (); p = this.gameObject.AddComponent<TREE>(); p.setDefaultJoint( defaultJoint); TREEUtils.makeDictionary (p.gameObject); p.generate ( "joints", "1,1", "rads", "3,24", "angles", "120,90", "length", "2.7,5.5", "divs", "1,1", "start", "0,0" ); xForm2.Setup( new string[]{ // "0|-1|-1|-1|-1|-1|-1", "0|-1|-1|-1|-1", "0|-1|-1", }, new string[]{ "ssrz:-1.3,sfrz:4.0,smrz:112,sMult:100.4", "ory:6,orx:4", // "ssrx:-1.3,sfrx:1.0,smrx:2,sMult:1.4" },p); GameObject g = TREEUtils.findJoint (new int[]{0,0,0}, 0, p.gameObject); }
// Use this for initialization void Start() { // // string dd = "0|-1|-1|-1|-1|-1|-1"; // string t = "0|-1|-1|-1|-1"; // string f = "0|-1|-1"; p = this.gameObject.AddComponent<TREE>(); p.setDefaultJoint( defaultJoint); p.generate ( "joints", "1,2", "rads", "3,24", "angles", "120,90", "length", "2.7,4.5", "divs", "1,1", "start", "0,0" ); // testList = TREEUtils.makeList (t, p.GetComponent<TREE>()); // testList2 = TREEUtils.makeList (f, p.GetComponent<TREE>()); // // testList3 = TREEUtils.makeList (dd, p.GetComponent<TREE>()); // // for (int i = 0; i < testList2.Count; i++) { // GameObject g = TREEUtils.findJoint (testList2 [i], 0, transform.GetChild (0).gameObject); // int j = g.GetComponent<Joint> ().joint; // g.transform.Rotate (new Vector3 (0, 0, 8)); //// g.transform.localScale = (new Vector3 (1/(j+.1f),1/(j+.1f),1/(j+.1f))); // } // xForm = new TreeTransform (); xForm.Setup( new string[]{ // "0|-1|-1|-1|-1|-1|-3", "0|-1|-1|-1|-1", "0|-1|-1", // "0|1|-2", }, new string[]{ "scale:.95,rx:5,ry:20", "scale:.87,ry:20" // "rx:45.5", // "rx:0", // "rx:0,nsrx:.3,nfrx:.133,nmrx:50,nMult:5", // "rx:0,ssrx:1.3,sfrx:.533,smrx:50,sMult:5,sorx:.4", },p); // "rx:0,srx:100,sfrx:1,ssrx:100,smrx:0", // "rx:0,srx:10,sfrx:.1,ssrx:-.3,smrx:60", // "rx:0,srx:10,sfrx:.5,ssrx:-.1,smrx:60", // // xForm.Update (); xForm2 = new TreeTransform (); // xForm2 = new TreeTransform (); xForm2.Setup( new string[]{ // "0|-1|-1|-1|-1|-1|-1", // "0|-1|-1|-1|-1", "0|-1|-1", }, new string[]{ // "ory:6,orx:5", "ory:6", // "ssrx:-1.3,sfrx:1.0,smrx:2,sMult:1.4" },p); GameObject g = TREEUtils.findJoint (new int[]{0,0,0}, 0, p.gameObject); }