Skip to content

Commit

Permalink
added CreateAssetToCurrentSelectionFolder<T>() for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ddionisio committed Mar 29, 2015
1 parent 6bbb9eb commit b20dcbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Editor/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,13 @@ public static string GetProjectName() {
public static string PreferenceKey(string klass, string field) {
return string.Format("m8.{0}.{1}.{2}", GetProjectName(), klass, field);
}

public static void CreateAssetToCurrentSelectionFolder<T>() where T : ScriptableObject {
var asset = ScriptableObject.CreateInstance<T>();

string dir = GetSelectionFolder();

ProjectWindowUtil.CreateAsset(asset, string.Format("{0}{1}.asset", dir, typeof(T).Name));
}
}
}
9 changes: 8 additions & 1 deletion Scripts/Utils/ArrayUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,20 @@ public static bool Contains(string[] src, string itm)
return false;
}

public static bool Contains<T>(T[] src, T itm) where T:Component {
public static bool Contains<T>(T[] src, T itm) where T:UnityEngine.Object {
if(src != null) {
for(int i = 0; i < src.Length; i++)
if(src[i] == itm)
return true;
}
return false;
}

public static int[] GenerateIndexArray(Array array) {
int[] indices = new int[array.Length];
for(int i = 0; i < indices.Length; i++)
indices[i] = i;
return indices;
}
}
}

0 comments on commit b20dcbb

Please sign in to comment.