static void HierarchyWindowOnGUI(int instanceId, Rect selectionRect) { GameObject go = EditorUtility.InstanceIDToObject(instanceId) as GameObject; if (go == null) { return; } Rect toggleRect = new Rect(selectionRect); toggleRect.x += toggleRect.width - 20; toggleRect.width = 18; EditorGUI.BeginChangeCheck(); // bool visible = GUI.Toggle(toggleRect, go.activeInHierarchy && go.activeSelf, string.Empty); if (EditorGUI.EndChangeCheck()) { } if (Selection.activeObject != null && Selection.activeObject is GameObject) { GameObject selectObj = Selection.activeObject != null ? (GameObject)Selection.activeObject : null; if (selectObj) { LuaMonoView graphic = selectObj.GetComponent <LuaMonoView>(); if (graphic != null && graphic.EditorLuaData != null) { List <LuaWindowDefine> allDynamicWins = (List <LuaWindowDefine>)graphic.EditorLuaData; foreach (LuaWindowDefine win in allDynamicWins) { Transform obj = selectObj.transform.Find(win.Name); if (obj != null && obj.gameObject.Equals(go)) { toggleRect.y += 6; toggleRect.x = 20; toggleRect.width = 5; toggleRect.height = 5; GUI.color = Color.green; GUI.DrawTexture(toggleRect, EditorGUIUtility.whiteTexture); GUI.color = Color.white; break; } } //end for } //end if } //end if } //end tiny }
protected void OnEnable() { LuaMonoView graphic = target as LuaMonoView; if (graphic != null) { graphic.EditorLuaData = null; } mGameobjectList = new ReorderableList(new List <string>(), typeof(string), false, true, false, false); mGameobjectList.showDefaultBackground = true; mGameobjectList.elementHeight = 20; mGameobjectList.drawHeaderCallback += new ReorderableList.HeaderCallbackDelegate(DrawLuaHeader); mGameobjectList.drawElementCallback += new ReorderableList.ElementCallbackDelegate(DrawLuaElement); mLuaFileName = serializedObject.FindProperty("mLuaFileName"); }
protected void DrawLuaElement(Rect rect, int index, bool isActive, bool isFocused) { LuaMonoView graphic = target as LuaMonoView; Transform tran = graphic.transform; rect.height = EditorGUIUtility.singleLineHeight; rect.x = 20; List <LuaWindowDefine> dataList = mGameobjectList.list as List <LuaWindowDefine>; LuaWindowDefine data = dataList[index]; Transform item = Selection.activeGameObject.transform.Find(data.Name); GameObject obj = item != null ? item.gameObject : null; string title = Utils.combine(data.Alias, "(", data.Type, ")"); EditorGUI.ObjectField(rect, title, obj, typeof(GameObject), true); }
public override void OnInspectorGUI() { LuaMonoView graphic = target as LuaMonoView; EditorGUILayout.PropertyField(mLuaFileName, new GUIContent("Lua脚本名")); if (graphic.mLuaFileName.Equals("") == false) { GUILayout.BeginHorizontal(); if (GUILayout.Button("查看LuaMonoView")) { string path = System.Environment.CurrentDirectory + "/Assets/Script/Lua"; List <string> fileList = new List <string>(); var files = this.FindLuaFile(path, fileList); foreach (string name in files) { int lastIndexOfPoint = name.LastIndexOf('.'); int lastIndexOfDash = name.LastIndexOf('\\') + 1; int len = lastIndexOfPoint - lastIndexOfDash; string luaName = name.Substring(lastIndexOfDash, len); if (luaName.Equals(graphic.mLuaFileName)) { this._allDic = this.ParseLuaFileToShowList(name); if (this._allDic.Count > 0) { graphic.EditorLuaData = this._allDic; } break; } } } GUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); //绘制关系图 this.DrawLuaPanel(); }//end func