void TemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData) { if (OnTemplateDragEnd != null) { OnTemplateDragEnd(template, unit, pointerData); } }
void TemplateClicked(UnitUITemplate template, UnitTemplate data) { if (OnClick != null) { OnClick(template, data); } }
void ListTemplateDrag(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData) { if (Instance == null) { } else { if (Instance.Template == template.Template) { SetTemplatePosition(pointerData); } } }
void ListTemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData) { if (Instance == null) { } else { Destroy(Instance.gameObject); Instance = null; Selection.Context.Apply(); if (OnDragEnd != null) { OnDragEnd(); } } }
public override void Init() { base.Init(); Templates = new UnitUITemplate[List.Count]; Player.Inventory.OnUpdate += InventroyUpdateCallback; for (int i = 0; i < List.Count; i++) { Templates[i] = CreateTemplate(List[i]); Templates[i].OnClick += TemplateClicked; Templates[i].DragBeginEvent += TemplateDragBegin; Templates[i].DragEvent += TemplateDrag; Templates[i].DragEndEvent += TemplateDragEnd; } UpdateState(); }
UnitUITemplate CreateTemplate(UnitUITemplate source) { var instance = Instantiate(template, RectTransform); instance.name = source.Template.name + " Drag Template"; var script = instance.GetComponent <UnitUITemplate>(); script.Init(); script.Set(source.Template); script.LayoutElement.ignoreLayout = true; script.CanvasGroup.blocksRaycasts = false; script.CanvasGroup.alpha = 0.6f; script.Lock.Active = false; script.RectTransform.sizeDelta = source.RectTransform.sizeDelta * 0.8f; return(script); }
void ListTemplateDragBegin(UnitUITemplate UITemplate, UnitTemplate template, PointerEventData pointerData) { if (Instance == null) { if (Player.Inventory.Contains(template.CatalogItem)) { Selection.Context.Start(UITemplate.Template); Instance = CreateTemplate(UITemplate); SetTemplatePosition(pointerData); if (OnDragBegin != null) { OnDragBegin(); } } } else { } }
void OnListUnitClicked(UnitUITemplate template, UnitTemplate data) { Context.Show(data); }