public static void Remove(BlueprintModelAsset instance) { var path = AssetDatabase.GetAssetPath(instance); DestroyImmediate(instance, true); AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate); }
/// <summary> /// EDITOR ONLY: Used to remove a group and all it's blueprints from the model. /// </summary> public void Delete(BlueprintGroup g) { foreach (var u in blueprints.ToArray()) { if (u.group == g) { Delete(u); } } groups.Remove(g); BlueprintModelAsset.Remove(g); }
public void Delete(UnitStat stat) { foreach (var u in blueprints) { foreach (var c in u.statValues.ToArray()) { if (c.stat == stat) { u.statValues.Remove(c); } } } stats.Remove(stat); BlueprintModelAsset.Remove(stat); }
/// <summary> /// EDITOR ONLY: Used to delete a resource and remove it from all blueprints. /// </summary> public void Delete(Resource resource) { foreach (var u in blueprints) { foreach (var c in u.costs.ToArray()) { if (c.resource == resource) { u.costs.Remove(c); } } } resources.Remove(resource); BlueprintModelAsset.Remove(resource); }
public static T Create <T>(BlueprintModelAsset nextTo = null) where T : BlueprintModelAsset { var instance = ScriptableObject.CreateInstance <T>(); var root = "Assets"; if (nextTo != null) { AssetDatabase.AddObjectToAsset(instance, nextTo); } else { var path = AssetDatabase.GenerateUniqueAssetPath(string.Format("{0}/{1}.asset", root, typeof(T).Name)); AssetDatabase.CreateAsset(instance, path); } instance.OnCreate(); return(instance); }
/// <summary> /// EDITOR ONLY: Used to delete a blueprint and remove it from all other blueprints. /// </summary> public void Delete(Blueprint unit) { foreach (var u in blueprints.ToArray()) { foreach (var p in u.prerequisites.ToArray()) { if (p == unit) { u.prerequisites.Remove(p); } } if (u == unit) { blueprints.Remove(u); } } BlueprintModelAsset.Remove(unit); }
public static void Rename(BlueprintModelAsset instance, string newName) { newName = instance.GetType().Name + "-" + newName; instance.name = newName; }