public override void OnInspectorGUI() { if (_nativeEditor != null) { // check if it is a PSD file selected string assetPath = ((TextureImporter)target).assetPath; if (assetPath.EndsWith(PsdImporter.PSD_TAIL)) { GUILayout.Label("<b>PSD Layout Tool</b>", _guiStyle, GUILayout.Height(23)); //set ui width and height; GUIContent screenSize = new GUIContent("屏幕分辨率", "UI 宽*高"); PsdImporter.ScreenResolution = EditorGUILayout.Vector2Field(screenSize, PsdImporter.ScreenResolution); GUIContent imageSizeLimit = new GUIContent("小图限制(超过该尺寸 建议拆分图集)", "小图尺寸限制(超过该尺寸 建议拆出图集)"); PsdImporter.LargeImageAlarm = EditorGUILayout.Vector2Field(imageSizeLimit, PsdImporter.LargeImageAlarm); //set textFont GUIContent fontName = new GUIContent("字体名称", "字体名称"); PsdImporter.textFont = EditorGUILayout.TextField(fontName, PsdImporter.textFont); if (GUILayout.Button("Layout in Current Scene")) { PsdImporter.LayoutInCurrentScene(assetPath); } if (GUILayout.Button("Generate Prefab")) { PsdImporter.GeneratePrefab(assetPath); } GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUILayout.Label("<b>Unity Texture Importer Settings</b>", _guiStyle, GUILayout.Height(23)); // draw the default Inspector for the PSD _nativeEditor.OnInspectorGUI(); } else { // It is a "normal" Texture, not a PSD _nativeEditor.OnInspectorGUI(); } } }
/// <summary> /// Draws the Inspector GUI for the TextureImporter. /// Normal Texture files should appear as they normally do, however PSD files will have additional items. /// </summary> public override void OnInspectorGUI() { if (nativeEditor != null) { // check if it is a PSD file selected string assetPath = ((TextureImporter)target).assetPath; if (assetPath.EndsWith(".psd")) { GUILayout.Label("<b>PSD Layout Tool</b>", guiStyle, GUILayout.Height(23)); GUIContent maximumDepthLabel = new GUIContent("Maximum Depth", "The Z value of the far back plane. The PSD will be laid out from here to 0."); PsdImporter.MaximumDepth = EditorGUILayout.FloatField(maximumDepthLabel, PsdImporter.MaximumDepth); GUIContent pixelsToUnitsLabel = new GUIContent("Pixels to Unity Units", "The scale of the Sprite objects, in the number of pixels to Unity world units."); PsdImporter.PixelsToUnits = EditorGUILayout.FloatField(pixelsToUnitsLabel, PsdImporter.PixelsToUnits); //GUIContent useUnityUILabel = new GUIContent("Use Unity UI", "Create Unity UI elements instead of \"normal\" GameObjects."); //PsdImporter.UseUnityUI = EditorGUILayout.Toggle(useUnityUILabel, PsdImporter.UseUnityUI); GUIContent addCanvasUILabel = new GUIContent("Add Canvas", "Add Canvas on the GameObjects."); PsdImporter.CreateCanvas = EditorGUILayout.Toggle(addCanvasUILabel, PsdImporter.CreateCanvas); // draw our custom buttons for PSD files //if (GUILayout.Button("Export Layers as Textures")) //{ // PsdImporter.ExportLayersAsTextures(assetPath); //} //if (GUILayout.Button("Layout in Current Scene")) //{ // PsdImporter.LayoutInCurrentScene(assetPath); //} if (GUILayout.Button("Generate Prefab")) { string prefabFullPath = GetPrefabFullPath(assetPath); if (System.IO.File.Exists(prefabFullPath)) { bool b = UnityEditor.EditorUtility.DisplayDialog("提示", prefabFullPath + "已经存在,要替换吗?", "确定", "取消"); if (!b) { return; } } PsdImporter.GeneratePrefab(assetPath); } if (GUILayout.Button("Delete Prefab")) { string prefabAssetPath = PsdImporter.prefabPath + System.IO.Path.GetFileNameWithoutExtension(assetPath); prefabAssetPath = PsdImporter.GetRelativePath(prefabAssetPath); bool b = UnityEditor.EditorUtility.DisplayDialog("提示", "确定要删除 " + prefabAssetPath + " 吗?", "确定", "取消"); if (b) { bool ret = AssetDatabase.DeleteAsset(prefabAssetPath + ".prefab"); if (ret) { AssetDatabase.Refresh(); } } } GUILayout.Space(6); //GUIContent usemde = new GUIContent("compare textures by md5", "use md5"); //PsdImporter.UseMd5 = EditorGUILayout.Toggle(usemde, PsdImporter.UseMd5); if (GUILayout.Button("Delete Repeat sprites (all psd files)")) { PsdImporter.DeleteRepeatSprites(PsdImporter.UseMd5); } //if (GUILayout.Button("Delete Repeat sprites (current psd file)")) //{ // PsdImporter.DeleteCurrentPsdRepeatSprites(System.IO.Path.GetFileNameWithoutExtension(assetPath), PsdImporter.UseMd5); //} if (GUILayout.Button("Delete unused sprites")) { PsdImporter.DeleteUnusedSprites(); } GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUILayout.Label("<b>Unity Texture Importer Settings</b>", guiStyle, GUILayout.Height(23)); // draw the default Inspector for the PSD nativeEditor.OnInspectorGUI(); } else if (assetPath.EndsWith(".png")) { if (GUILayout.Button("delete other repeat images")) { string fullname = PsdImporter.GetFullProjectPath() + assetPath; PsdImporter.DeleteRepeatSpritesNameof(fullname); } if (GUILayout.Button("find all refenerce")) { PsdImporter.PrintAllReference(assetPath); } nativeEditor.OnInspectorGUI(); } else { // It is a "normal" Texture, not a PSD nativeEditor.OnInspectorGUI(); } } // Unfortunately we cant hide the ImportedObject section because the interal InspectorWindow checks via // "if (editor is AssetImporterEditor)" and all flags that this check sets are method local variables // so aside from direct patching UnityEditor.dll, reflection cannot be used here. // Therefore we just move the ImportedObject section out of view ////GUILayout.Space(2048); }
/// <summary> /// Draws the Inspector GUI for the TextureImporter. /// Normal Texture files should appear as they normally do, however PSD files will have additional items. /// </summary> public override void OnInspectorGUI() { if (nativeEditor != null) { // check if it is a PSD file selected string assetPath = ((TextureImporter)target).assetPath; if (assetPath.EndsWith(PsdImporter.PSD_TAIL)) { GUILayout.Label("<b>PSD Layout Tool</b>", guiStyle, GUILayout.Height(23)); //All ui depth is the same 1 //GUIContent maximumDepthLabel = new GUIContent("Maximum Depth", "The Z value of the far back plane. The PSD will be laid out from here to 0."); //PsdImporter.MaximumDepth = EditorGUILayout.FloatField(maximumDepthLabel, PsdImporter.MaximumDepth); //modify by yanru //GUIContent pixelsToUnitsLabel = new GUIContent("Pixels to Unity Units", "The scale of the Sprite objects, in the number of pixels to Unity world units."); //PsdImporter.PixelsToUnits = EditorGUILayout.FloatField(pixelsToUnitsLabel, PsdImporter.PixelsToUnits); //GUIContent useUnityUILabel = new GUIContent("Use Unity UI", "Create Unity UI elements instead of \"normal\" GameObjects."); //PsdImporter.UseUnityUI = EditorGUILayout.Toggle(useUnityUILabel, PsdImporter.UseUnityUI); //set ui width and height; GUIContent screenSize = new GUIContent("屏幕分辨率", "UI 宽*高"); PsdImporter.ScreenResolution = EditorGUILayout.Vector2Field(screenSize, PsdImporter.ScreenResolution); GUIContent imageSizeLimit = new GUIContent("小图限制(超过该尺寸 建议拆分图集)", "小图尺寸限制(超过该尺寸 建议拆出图集)"); PsdImporter.LargeImageAlarm = EditorGUILayout.Vector2Field(imageSizeLimit, PsdImporter.LargeImageAlarm); //set textFont GUIContent fontName = new GUIContent("字体名称", "字体名称"); PsdImporter.textFont = EditorGUILayout.TextField(fontName, PsdImporter.textFont); //force use fullScreenUI //GUIContent useFullScreenUI = new GUIContent("useFullScreenUI", "useFullScreenUI"); //PsdImporter.fullScreenUI = EditorGUILayout.Toggle(useFullScreenUI, PsdImporter.fullScreenUI); // draw our custom buttons for PSD files //if (GUILayout.Button("Export Layers as Textures")) //{ // PsdImporter.ExportLayersAsTextures(assetPath); //} if (GUILayout.Button("Layout in Current Scene")) { PsdImporter.LayoutInCurrentScene(assetPath); } if (GUILayout.Button("Layout in Current Scene(use image real size)")) { PsdImporter.LayoutInCurrentScene(assetPath, true); } if (GUILayout.Button("Generate Prefab")) { PsdImporter.GeneratePrefab(assetPath); } if (GUILayout.Button("test ClickButton")) { PsdImporter.TestClick(); } GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUILayout.Label("<b>Unity Texture Importer Settings</b>", guiStyle, GUILayout.Height(23)); // draw the default Inspector for the PSD nativeEditor.OnInspectorGUI(); } else { // It is a "normal" Texture, not a PSD nativeEditor.OnInspectorGUI(); } } // Unfortunately we cant hide the ImportedObject section because the interal InspectorWindow checks via // "if (editor is AssetImporterEditor)" and all flags that this check sets are method local variables // so aside from direct patching UnityEditor.dll, reflection cannot be used here. // Therefore we just move the ImportedObject section out of view ////GUILayout.Space(2048); }
/// <summary> /// Draws the Inspector GUI for the TextureImporter. /// Normal Texture files should appear as they normally do, however PSD files will have additional items. /// </summary> public override void OnInspectorGUI() { if (nativeEditor != null) { // check if it is a PSD file selected string assetPath = ((TextureImporter)target).assetPath; if (assetPath.EndsWith(".psd")) { GUILayout.Label("<b>PSD Layout Tool</b>", guiStyle, GUILayout.Height(23)); GUIContent maximumDepthLabel = new GUIContent("Maximum Depth", "The Z value of the far back plane. The PSD will be laid out from here to 0."); PsdImporter.MaximumDepth = EditorGUILayout.FloatField(maximumDepthLabel, PsdImporter.MaximumDepth); GUIContent pixelsToUnitsLabel = new GUIContent("Pixels to Unity Units", "The scale of the Sprite objects, in the number of pixels to Unity world units."); PsdImporter.PixelsToUnits = EditorGUILayout.FloatField(pixelsToUnitsLabel, PsdImporter.PixelsToUnits); GUIContent useUnityUILabel = new GUIContent("Use Unity UI", "Create Unity UI elements instead of \"normal\" GameObjects."); PsdImporter.UseUnityUI = EditorGUILayout.Toggle(useUnityUILabel, PsdImporter.UseUnityUI); // draw our custom buttons for PSD files if (GUILayout.Button("Export Layers as Textures")) { PsdImporter.ExportLayersAsTextures(assetPath); } if (GUILayout.Button("Layout in Current Scene")) { PsdImporter.LayoutInCurrentScene(assetPath); } if (GUILayout.Button("Generate Prefab")) { PsdImporter.GeneratePrefab(assetPath); } GUILayout.Space(3); GUILayout.Box(string.Empty, GUILayout.Height(1), GUILayout.MaxWidth(Screen.width - 30)); GUILayout.Space(3); GUILayout.Label("<b>Unity Texture Importer Settings</b>", guiStyle, GUILayout.Height(23)); // draw the default Inspector for the PSD nativeEditor.OnInspectorGUI(); } else { // It is a "normal" Texture, not a PSD nativeEditor.OnInspectorGUI(); } } // Unfortunately we cant hide the ImportedObject section because the interal InspectorWindow checks via // "if (editor is AssetImporterEditor)" and all flags that this check sets are method local variables // so aside from direct patching UnityEditor.dll, reflection cannot be used here. // Therefore we just move the ImportedObject section out of view ////GUILayout.Space(2048); }