//public string GetPath(bool isGet) //{ // string path = gameObject.name; // Transform tsTp = gameObject.transform; // if (isGet) // { // while (tsTp.parent && !tsTp.parent.name.Equals(_root)) // { // path = path.Insert(0, tsTp.parent.name + "/"); // tsTp = tsTp.parent; // } // return "SetTransform(\"" + path + "\")"; // } // return ""; //} public static string GetBindDataName(RegistViewItem item) { if (!string.IsNullOrEmpty(item.BindDataName)) { return("BindModel(\"" + item.BindDataName.Trim() + "\")"); } return(null); }
private void OnSaveButtonClick() { for (int i = 0; i < itemList.Count; i++) { RegistViewItem item = itemList[i]; item.name = tpNameList[i]; item.IsBindPath = tpIsBindList[i]; item.BindDataName = tpBindNameList[i]; } }
private void OnGUI_EditorRegistViewItem(RegistViewItem item, int index) { GUILayout.BeginVertical(); OnGUI_EditorItemName(item, index); GUI.color = Color.white; OnGUI_EditorItemIsBindPath(item, index); OnGUI_EditorItemBindData(item, index); GUILayout.EndVertical(); Layout_DrawSeparator(Color.gray, 2); }
private void OnGUI_EditorItemBindData(RegistViewItem item, int index) { GUILayout.BeginHorizontal(); string tpName = tpNameList[index]; GUILayout.Label("绑定数据:", GUILayout.Width(70)); GUI.color = item.BindDataName == tpBindNameList[index] ? Color.white : Color.yellow; tpBindNameList[index] = GUILayout.TextField(tpBindNameList[index], GUILayout.Width(180)); if (GUILayout.Button("保存", GUILayout.Width(70))) { item.BindDataName = tpBindNameList[index]; AssetDatabase.SaveAssets(); } GUILayout.EndHorizontal(); }
private void GetRegistViewItems(Transform ts, ref List <RegistViewItem> itemList) { RegistViewItem item = ts.GetComponent <RegistViewItem>(); if (item) { itemList.Add(item); } if (ts.childCount > 0) { for (int i = 0; i < ts.childCount; i++) { GetRegistViewItems(ts.GetChild(i), ref itemList); } } }
private void OnGUI_EditorItemIsBindPath(RegistViewItem item, int index) { GUILayout.BeginHorizontal(); GUI.color = item.IsBindPath == tpIsBindList[index] ? Color.white : Color.yellow; string tp = string.Format(" 自动设置节点:{0}", tpIsBindList[index] ? Editor_UITool.GetBindPath(item.gameObject, targetName) : ""); tpIsBindList[index] = GUILayout.Toggle(tpIsBindList[index], "", GUILayout.Width(10)); //var oc = GUI.color; //GUI.color = Color.green; GUILayout.Label(tp); //GUI.color = oc; if (GUILayout.Button("保存", GUILayout.Width(70))) { item.IsBindPath = tpIsBindList[index]; AssetDatabase.SaveAssets(); } GUILayout.EndHorizontal(); }
private void OnGUI_EditorItemName(RegistViewItem item, int index) { GUILayout.BeginHorizontal(); string tpName = tpNameList[index]; int count = (tpNameList.GroupBy(x => x).Where(x => x.Count() > 1)).Where(x => x.Key == tpName).ToList().Count(); GUI.color = count > 0 ? Color.red : Color.white; if (GUI.color != Color.red) { GUI.color = item.name == tpNameList[index] ? Color.white : Color.yellow; } GUILayout.Label("Name:", GUILayout.Width(50)); tpNameList[index] = GUILayout.TextField(tpNameList[index], GUILayout.Width(200)); if (GUILayout.Button("保存", GUILayout.Width(70))) { item.name = tpNameList[index]; AssetDatabase.SaveAssets(); } GUILayout.EndHorizontal(); }