public override void OnInspectorGUI() { RectTransform rect = target as RectTransform; if (rect == null) { base.OnInspectorGUI(); return; } string assetPath = AssetDatabase.GetAssetPath(rect.gameObject); string asset = PsdLayoutTool.PsdImporter.GetRelativePath(ResDefine.GetResPath(EResType.eResUI)); if (assetPath.Contains(asset)) { base.OnInspectorGUI(); GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUIContent autoBind = new GUIContent("autoBindView", "auto bind view to prefab"); BindView.AutoBindView = EditorGUILayout.Toggle(autoBind, BindView.AutoBindView); //if (GUILayout.Button("Generate CS View Script")) //{ // string prefabFullPath = GetPrefabFullPath(assetPath); // if (!System.IO.File.Exists(prefabFullPath)) // { // UnityEditor.EditorUtility.DisplayDialog("提示", "没有找到prefab文件,请先生成prefab", "确定"); // return; // } // BindView.GenerateView(assetPath, ScriptType.eCSharp); //} //GUILayout.Space(3); if (GUILayout.Button("Generate Lua View Script")) { BindView.GenerateView(assetPath, ScriptType.eLua); } if (GUILayout.Button("Delete bind Script")) { //string CSAssetPath = BindView.UICSViewPath + System.IO.Path.GetFileNameWithoutExtension(assetPath); //bool ret = AssetDatabase.DeleteAsset(CSAssetPath + ".cs"); string LuaAssetPath = BindView.UILuaViewPath + System.IO.Path.GetFileNameWithoutExtension(assetPath); bool ret = AssetDatabase.DeleteAsset(LuaAssetPath + ".lua"); if (ret) { AssetDatabase.Refresh(); } } if (GUILayout.Button("Delete Repeat sprites")) { PsdLayoutTool.PsdImporter.DeleteCurrentPsdRepeatSprites(System.IO.Path.GetFileNameWithoutExtension(assetPath), false); } } else { base.OnInspectorGUI(); } }
public override void OnInspectorGUI() { GameObject rect = Selection.activeGameObject; if (rect == null) { base.OnInspectorGUI(); return; } string curSelectedPath = AssetDatabase.GetAssetPath(rect.gameObject); string assetPath = ""; if (string.IsNullOrEmpty(curSelectedPath)) { // 如果直接获得路径失败,尝试获得当前选中对象的关联父Prefab var curSelectedParentPrefab = PrefabUtility.GetCorrespondingObjectFromSource(rect); assetPath = AssetDatabase.GetAssetPath(curSelectedParentPrefab); } else { assetPath = curSelectedPath; } base.OnInspectorGUI(); GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUIContent autoBind = new GUIContent("autoBindView", "auto bind view to prefab"); //BindView.AutoBindView = EditorGUILayout.Toggle(autoBind , BindView.AutoBindView); GUILayout.Space(3); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Generate Lua View")) { BindView.GenerateView(assetPath, ScriptType.eLua); } if (GUILayout.Button("Generate Lua View All")) { BindView.GenerateViewAll(ScriptType.eLua); } //if (GUILayout.Button("Delete bind Script")) //{ // string luaAssetPath = BindView.UILuaViewPath + Path.GetFileNameWithoutExtension(assetPath) + ".lua"; // File.Delete(luaAssetPath); //} if (GUILayout.Button("Generate UICtrl")) { CreateCtrlWnd.ShowWindow(); } } GUILayout.Space(3); }