internal override void Initialize() { renderer = GetComponent <Renderer>(); rTarget = AddComponent <RayCastTarget>(); rTarget.OnMoveInEvent += MoveIn; rTarget.OnMoveOutEvent += MoveOut; rTarget.OnClickEvent += Click; }
/// <summary> /// 移除系统 /// </summary> public void RemoveFromSystem(RayCastTarget UITarget, Vector2 position) { foreach (Vector2 dis in UITarget.GameObject.PosList) { Vector2 pos = position + dis; if (UITargets.ContainsKey(pos)) { UITargets[pos].Remove(UITarget); if (UITargets[pos].Count == 0) { UITargets.Remove(pos); } } } }
/// <summary> /// 加入系统 /// </summary> public void AddToSystem(RayCastTarget UITarget, Vector2 position) { foreach (Vector2 dis in UITarget.GameObject.PosList) { Vector2 pos = position + dis; if (UITargets.ContainsKey(pos)) { UITargets[pos].Add(UITarget); } else { UITargets.Add(pos, new List <RayCastTarget>() { UITarget }); } } }
internal override void Initialize() { listBoxCom = GameObject.Parent.GetComponent <ListBox>(); List <Vector2> meshList = new List <Vector2>(); for (int i = 0; i < listBoxCom.Width; i++) { meshList.Add(new Vector2(i, 0)); } GameObject.InitMesh(meshList); //添加一个Renderer组件 renderer = AddComponent <Renderer>(); renderer.Init(RendererMode.UI, -1); //添加一个Label组件 BackColor = Color.Yellow; rtarget = AddComponent <RayCastTarget>(); rtarget.OnClickEvent += () => { listBoxCom.OnClickAction(Index); }; }