internal static InterfaceButton CreateButton(GameObject go, string btnName, InterfaceButtonMode btnMode, Action <string, object> onButtonClick, Color startColor, Color hoverColor, float maxInteractionRange) { var button = go.AddComponent <InterfaceButton>(); button.BtnName = btnName; button.ButtonMode = btnMode; button.STARTING_COLOR = startColor; button.HOVER_COLOR = hoverColor; button.OnButtonClick = onButtonClick; button.MaxInteractionRange = maxInteractionRange; return(button); }
internal static InterfaceButton CreateButton(GameObject go, string btnName, InterfaceButtonMode btnMode, Action <string, object> onButtonClick, Color startColor, Color hoverColor, float maxInteractionRange, Sprite icon, string lineOne, string lineTwo = "") { var button = go.AddComponent <InterfaceButton>(); button.BtnName = btnName; button.ButtonMode = btnMode; button.STARTING_COLOR = startColor; button.HOVER_COLOR = hoverColor; button.OnButtonClick = onButtonClick; button.MaxInteractionRange = maxInteractionRange; button.TextLineOne = lineOne; button.TextLineTwo = lineTwo; var image = go.EnsureComponent <Image>(); image.sprite = icon; return(button); }
internal static InterfaceButton CreateButton(GameObject go, string btnName, InterfaceButtonMode btnMode, Action <string, object> onButtonClick, Color startColor, Color hoverColor, float maxInteractionRange, string lineOne, string lineTwo = "") { if (go == null) { QuickLogger.Error <InterfaceHelpers>($"GameObject for button {btnName} is null"); } var button = go.AddComponent <InterfaceButton>(); button.BtnName = btnName; button.ButtonMode = btnMode; button.STARTING_COLOR = startColor; button.HOVER_COLOR = hoverColor; button.OnButtonClick = onButtonClick; button.MaxInteractionRange = maxInteractionRange; button.TextLineOne = lineOne; button.TextLineTwo = lineTwo; return(button); }
internal static bool CreateButton(GameObject parent, string childName, string btnName, InterfaceButtonMode btnMode, Color startColor, Color hoverColor, Action <string, object> onButtonClick, out InterfaceButton customButton) { customButton = null; var go = parent.FindChild(childName)?.gameObject; if (go == null) { QuickLogger.Error($"{childName} cannot be found"); return(false); } var button = go.AddComponent <InterfaceButton>(); button.BtnName = btnName; button.ButtonMode = btnMode; button.STARTING_COLOR = startColor; button.HOVER_COLOR = hoverColor; button.OnButtonClick = onButtonClick; customButton = button; return(true); }
internal static bool CreateButton(GameObject parent, string childName, string btnName, InterfaceButtonMode btnMode, Action <string, object> onButtonClick, out InterfaceButton button) { var result = CreateButton(parent, childName, btnName, btnMode, Color.white, ColorBlue, onButtonClick, out InterfaceButton cusButton); button = cusButton; return(result); }