/// <summary> /// Launches the pathfinding algorithm and attempts to find a <see cref="Path"/> between the start and end <see cref="Index"/>. /// This overload accepts a <see cref="MonoDelegate"/> as a callback. /// </summary> /// <param name="start">The start position for the search</param> /// <param name="end">The end position for the search</param> /// <param name="diagonal">The diagonal mod used when finding paths</param> /// <param name="callback">The <see cref="MonoDelegate"/> to invoke on completion</param> public void findPath(Index start, Index end, DiagonalMode diagonal, MonoDelegate callback) { // Call through findPath(start, end, diagonal, (Path path, PathRequestStatus status) => { // Invoke the mono delegate callback.invoke(new MonoDelegateEvent(path, status)); }); }
public static void registEvent(UIScrollBar scrollBar, Action function) { MonoDelegate d = scrollBar.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = scrollBar.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; scrollBar.onChange.Clear(); scrollBar.onChange.Add(new EventDelegate(d, "function")); }
internal static void registEvent(UIButton btn, Action function) { if (btn != null) { MonoDelegate d = btn.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = btn.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(d, "function")); return; } }
public void Start() { // This example assumes that there is a valid AStar grid component in the scene. // The included TileManager script can be used in this case. AStarAbstractGrid grid = AStarGridManager.DefaultGrid; // Create our mono delegate targeting the 'onPathFound' method and specifying 'this' mono behaviour as the receiver. // Once created, the delegate can be stored and reused in multiple pathfinding requests. MonoDelegate callback = new MonoDelegate(this, "onPathFound"); // We are also able to add additional listeners to the mono delegate which will also be called. callback.addListener(this, "onPathFoundAdditional"); // Issue a pathfinding request using our mono delegate as the callback grid.findPath(new Index(0, 0), new Index(1, 1), callback); }
public static void addButtonEvent_toolShift(GameObject father, string name, Action function) { UIButton btn = getByName <UIButton>(father, name); if (btn != null) { MonoDelegate d = btn.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = btn.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(btn.gameObject.GetComponent <toolShift>(), "shift")); btn.onClick.Add(new EventDelegate(d, "function")); } }
public static void registEventbtn(GameObject father, string name, Action function) { UIButton btn = getByName <UIButton>(father, name); if (btn != null) { MonoDelegate d = btn.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = btn.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(d, "function")); return; } }
protected override void OnEnable() { #if UNITY_EDITOR if (!Application.isPlaying) { mInitDone = false; return; } #endif if (isEnabled) { if (mInitDone) { if (UICamera.currentScheme == UICamera.ControlScheme.Controller) { OnHover(UICamera.selectedObject == gameObject); } else if (UICamera.currentScheme == UICamera.ControlScheme.Mouse) { OnHover(UICamera.hoveredObject == gameObject); } else { SetState(State.Normal, false); } } } else { SetState(State.Disabled, true); } if (action == null) { action = delegate(MonoBehaviour mono) { EventDelegate.Execute(onClick); }; } }
public static void registEvent(GameObject father, string name, Action function) { UISlider slider = getByName <UISlider>(father, name); if (slider != null) { MonoDelegate d = slider.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = slider.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; slider.onChange.Add(new EventDelegate(d, "function")); return; } UIPopupList list = getByName <UIPopupList>(father, name); if (list != null) { MonoDelegate d = list.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = list.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; list.onChange.Add(new EventDelegate(d, "function")); return; } UIToggle tog = getByName <UIToggle>(father, name); if (tog != null) { MonoDelegate d = tog.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = tog.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; tog.onChange.Clear(); tog.onChange.Add(new EventDelegate(d, "function")); return; } UIInput input = getByName <UIInput>(father, name); if (input != null) { MonoDelegate d = input.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = input.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; input.onSubmit.Clear(); input.onSubmit.Add(new EventDelegate(d, "function")); return; } UIScrollBar bar = getByName <UIScrollBar>(father, name); if (bar != null) { MonoDelegate d = bar.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = bar.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; bar.onChange.Clear(); bar.onChange.Add(new EventDelegate(d, "function")); return; } UIButton btn = getByName <UIButton>(father, name); if (btn != null) { MonoDelegate d = btn.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = btn.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(d, "function")); return; } }