protected override void DrawHeaderAddon() { var buttonText = "(None Selected)"; if (unit.variable != null) { buttonText = unit.macro.title + "." + unit.variable.name; } if (GUI.Button(position.Add().X(42).Add().Y(23).Set().Height(20).Set().Width(missingContent ? 120 : GUI.skin.label.CalcSize(new GUIContent(unit.macro?.title + "." + unit.variable?.name)).x + buttonPadding), buttonText)) { var classes = HUMAssets.Find().Assets().OfType <ClassMacro>(); GenericMenu menu = new GenericMenu(); for (int i = 0; i < classes.Count; i++) { for (int j = 0; j < classes[i].variables.variables.Count; j++) { menu.AddItem(new GUIContent(classes[i].title + "/" + classes[i].variables.variables[j].name), false, (data) => { var tuple = (ValueTuple <ClassMacro, Variable>)data; unit.macro = tuple.Item1; unit.memberName = tuple.Item2.name; unit.variable = tuple.Item2; unit.variable.Changed(); unit.Define(); }, (classes[i], classes[i].variables.variables[j])); } } menu.ShowAsContext(); } }
internal static void GenerateLive() { var assets = HUMAssets.Find().Assets().OfType <ClassMacro>(); for (int i = 0; i < assets.Count; i++) { ClassMacroGenerator.GetDecorator(assets[i]).GenerateLiveCode(); } var enumAssets = HUMAssets.Find().Assets().OfType <EnumMacro>(); for (int i = 0; i < enumAssets.Count; i++) { EnumMacroGenerator.GetDecorator(enumAssets[i]).GenerateLiveCode(); } var interfaceAssets = HUMAssets.Find().Assets().OfType <InterfaceMacro>(); for (int i = 0; i < interfaceAssets.Count; i++) { InterfaceMacroGenerator.GetDecorator(interfaceAssets[i]).GenerateLiveCode(); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public static T CreateAsset <T>(string defaultName = "") where T : TypeMacro { var macro = CreateInstance <T>(); macro.title = defaultName; AssetDatabase.CreateAsset(macro, HUMAssets.ProjectWindowPath() + "/" + macro.title.Add().Space().Between().Lowercase().And().Uppercase() + " " + macro.GetInstanceID().ToString().Replace("-", string.Empty) + ".asset"); macro.Define(); return(macro); }
private static void DelayInitialize() { HUMFlow.AfterTicks(ref ticks, 4, afterTicks: () => { var macros = HUMAssets.Find().Assets().OfType <TypeMacro>(); for (int i = 0; i < macros.Count; i++) { macros[i].Define(); } EditorApplication.update -= DelayInitialize; isInitializing = false; }); }
public static void DefineAllGraphsOfType <T>() where T : IUnit { var assets = HUMAssets.Find().Assets().OfType <ClassMacro>(); for (int i = 0; i < assets.Count; i++) { for (int j = 0; j < assets[i].methods.custom.Count; j++) { var units = assets[i].methods.custom[j].macro.graph.units.Where((u) => { return(u.GetType() == typeof(T)); }).ToArrayPooled(); for (int unit = 0; unit < units.Length; unit++) { units[unit].Define(); } } } }
public static List <T> With <T>(this HUMAssets.Data.Prefabs prefabs) where T : MonoBehaviour { var _prefabs = HUMAssets.Find().All().Prefabs(); var output = new List <T>(); foreach (GameObject prefab in _prefabs) { var validBehaviour = prefab.GetComponent <T>(); if (validBehaviour != null) { output.Add(validBehaviour); } } return(output); }
public static void DefineAllGraphs() { var assets = HUMAssets.Find().Assets().OfType <ClassMacro>(); for (int i = 0; i < assets.Count; i++) { for (int j = 0; j < assets[i].methods.custom.Count; j++) { var units = assets[i].methods.custom[j].macro.graph.units.ToArrayPooled(); for (int unit = 0; unit < units.Length; unit++) { units[unit].Define(); } } } }
private TypeMacro GetRootAsset(ClassMacro instance) { return(AssetDatabase.LoadAssetAtPath <TypeMacro>(AssetDatabase.GUIDToAssetPath(HUMAssets.GetGUID(instance)))); }