first push
This commit is contained in:
76
editor/ImageConverter.cs
Normal file
76
editor/ImageConverter.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace editor
|
||||
{
|
||||
public class ImageConverter : EditorWindow
|
||||
{
|
||||
[MenuItem("Tools/Image Converter Window")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<ImageConverter>("Image Converter");
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Image Converter", EditorStyles.boldLabel);
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label($"Selected: {Selection.objects.Length}");
|
||||
GUILayout.Space(20);
|
||||
if (GUILayout.Button("To Sprite"))
|
||||
{
|
||||
ConvertSelectedTexturesToSprites();
|
||||
}
|
||||
if (GUILayout.Button("To Default"))
|
||||
{
|
||||
ConvertSelectedTexturesToSDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConvertSelectedTexturesToSprites()
|
||||
{
|
||||
int count = 0;
|
||||
Debug.Log("Convert selected textures...");
|
||||
foreach (Object obj in Selection.objects)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
continue;
|
||||
|
||||
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
|
||||
textureImporter.textureType = TextureImporterType.Sprite;
|
||||
textureImporter.spriteImportMode = SpriteImportMode.Single;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
Debug.Log($"Converted {count} textures.");
|
||||
}
|
||||
|
||||
private static void ConvertSelectedTexturesToSDefault()
|
||||
{
|
||||
int count = 0;
|
||||
Debug.Log("Convert selected textures...");
|
||||
foreach (Object obj in Selection.objects)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
continue;
|
||||
|
||||
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (textureImporter == null)
|
||||
continue;
|
||||
|
||||
textureImporter.textureType = TextureImporterType.Default;
|
||||
textureImporter.spriteImportMode = SpriteImportMode.Multiple;
|
||||
textureImporter.SaveAndReimport();
|
||||
count++;
|
||||
}
|
||||
Debug.Log($"Converted {count} textures.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
editor/SceneSelectorWindow.cs
Normal file
60
editor/SceneSelectorWindow.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace editor
|
||||
{
|
||||
public class SceneSelectorWindow : EditorWindow
|
||||
{
|
||||
private string[] _scenePaths;
|
||||
private Vector2 _scrollPos;
|
||||
|
||||
[MenuItem("Tools/Scene Selector")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<SceneSelectorWindow>("Scene Selector");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
RefreshSceneList();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Scene Selector", EditorStyles.boldLabel);
|
||||
GUILayout.Space(10);
|
||||
if (GUILayout.Button("Refresh"))
|
||||
{
|
||||
RefreshSceneList();
|
||||
}
|
||||
GUILayout.Space(20);
|
||||
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos);
|
||||
foreach (var scenePath in _scenePaths)
|
||||
{
|
||||
if (GUILayout.Button(Path.GetFileNameWithoutExtension(scenePath)))
|
||||
{
|
||||
OpenScene(scenePath);
|
||||
}
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void RefreshSceneList()
|
||||
{
|
||||
_scenePaths = AssetDatabase.FindAssets("t:Scene", new[] { "Assets/Scenes" })
|
||||
.Select(AssetDatabase.GUIDToAssetPath)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void OpenScene(string scenePath)
|
||||
{
|
||||
if (UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
{
|
||||
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(scenePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user