public static UnityEngine.Object Load(ResourceType type, ResourceCategory category, string name, Type returnType) { string resourcePath = string.Format("{0}/{1}/{2}", type.ToString(), category.ToString(), name); UnityEngine.Object resource = Resources.Load(resourcePath, returnType); if (resource == null) { GameLogger.FatalError("ResourceLoader could not find resource {0}", resourcePath); } return(resource); }
public static string FindResourceName(int id, ResourceCategory category = ResourceCategory.Id) { if (resourceClassType == null) { return(null); } var categoryClassType = resourceClassType.GetNestedType(category.ToString()); // MQC TODO: Check if optimize perf by caching type for each category is needed? if (categoryClassType == null) { return(null); } return(Enum.GetName(categoryClassType, id)); }
public static int?FindResourceId(string name, ResourceCategory category = ResourceCategory.Id) { if (string.IsNullOrEmpty(name) || resourceClassType == null) { return(null); } var categoryClassType = resourceClassType.GetNestedType(category.ToString()); // MQC TODO: Check if optimize perf by caching type for each category is needed? if (categoryClassType == null) { return(null); } var fieldInfo = categoryClassType.GetField(name); if (fieldInfo == null) { return(null); } return((int)fieldInfo.GetValue(null)); }
public override string GetActionString() { return("Change Resource Amounts in Category " + resourceCategory.ToString() + " by min " + amountMin.ToString() + " and max " + amountMax.ToString()); }
public override string GetRequiermentString() { return(resourceAmount.ToString() + " in " + resourceCategory.ToString()); }
public static T[] LoadAll <T>(ResourceType type, ResourceCategory category) where T : UnityEngine.Object { string resourcePath = string.Format("{0}/{1}", type.ToString(), category.ToString()); return(Resources.LoadAll <T>(resourcePath)); }