2
« on: June 25, 2015, 03:12:15 pm »
Put this inside the Editor directory and use "Tools ->Move 2x" menu to get @2x out of your resources. To return @2x into build just drag the temp folder content back (from TempTk2dAssets to Resources/tk2d).
You MUST create TempTk2Assets folder manually or the script will not work.
For Unity 4 use Resources.LoadAssetAtPath instead of AssetDatabase.LoadAssetAtPath.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Move2x : ScriptableWizard
{
public string filter = "@2x";
public string path = "Assets/Resources/tk2d";
public string tempPath = "Assets/TempTk2dAssets";
[MenuItem("Tools/Move 2x")]
static void CreateWizard()
{
ScriptableWizard.DisplayWizard <Move2x>("Move 2x", "Move");
}
void OnWizardCreate()
{
string[] assets = AssetDatabase.FindAssets("tk2d", new string[]{path});
List<string> oldPathList = new List<string>();
List<string> newPathList = new List<string>();
for (int i = 0; i < assets.Length; i++)
{
string guid = assets[i];
string oldPath = AssetDatabase.GUIDToAssetPath(guid);
tk2dResource res = AssetDatabase.LoadAssetAtPath<tk2dResource>(oldPath);
if (res != null && res.objectReference != null && res.objectReference.name.Contains(filter))
{
oldPathList.Add(oldPath);
string newPath = oldPath.Replace(path, tempPath);
newPathList.Add(newPath);
AssetDatabase.MoveAsset(oldPath, newPath);
}
}
}
}