public int Register(Transform _Transform, Color _Color, EArrowType _Type) { ArrowRef newArrow = new ArrowRef(); GameObject m_ArrowPrefab; switch (_Type) { case EArrowType.BRUSH: m_ArrowPrefab = m_BrushArrowPrefab; break; case EArrowType.BUCKET: default: m_ArrowPrefab = m_BucketArrowPrefab; break; } newArrow.m_Target = _Transform; newArrow.m_Arrow = Instantiate(m_ArrowPrefab, this.transform); newArrow.m_Arrow.transform.GetChild(0).GetComponent <SpriteRenderer>().color = _Color; for (int i = 0; i < m_Refs.Count; ++i) { if (m_Refs [i] == null) { m_Refs [i] = newArrow; return(i); } } m_Refs.Add(newArrow); return(m_Refs.Count - 1); }
// SetupController<Generic> private static void SetupController <TComp>( ref GameObject myGO, Transform myParent, string myName, bool needMyComponent, EArrowType arrowType = EArrowType.none) where TComp : MonoBehaviour { myGO = new GameObject(myName, typeof(Image)); myGO.GetComponent <Image>().color = defaultColor; myGO.layer = LayerMask.NameToLayer("UI"); myGO.transform.localScale = Vector3.one; myGO.transform.SetParent(myParent); if (needMyComponent) { myGO.AddComponent <TComp>(); } if (arrowType != EArrowType.none) { myGO.GetComponent <TCKDPadArrow>().arrowType = arrowType; CalcDPadSizeAndPos(dpadMain.GetComponent <RectTransform>(), myGO.GetComponent <RectTransform>(), arrowType); } }
// CalcDPadSizeAndPos private static void CalcDPadSizeAndPos(RectTransform mainRect, RectTransform childRect, EArrowType arrowType) { childRect.sizeDelta = new Vector2(mainRect.sizeDelta.x / 3.4f, mainRect.sizeDelta.y / 3.4f); switch (arrowType) { case EArrowType.UP: childRect.anchoredPosition = new Vector2(0f, -childRect.sizeDelta.y / 2f); childRect.anchorMin = new Vector2(.5f, 1f); childRect.anchorMax = new Vector2(.5f, 1f); childRect.rotation = Quaternion.Euler(mainRect.rotation.x, mainRect.rotation.y, mainRect.rotation.z + 90f); break; case EArrowType.DOWN: childRect.anchoredPosition = new Vector2(0f, childRect.sizeDelta.y / 2f); childRect.anchorMin = new Vector2(.5f, 0f); childRect.anchorMax = new Vector2(.5f, 0f); childRect.rotation = Quaternion.Euler(mainRect.rotation.x, mainRect.rotation.y, mainRect.rotation.z + 270f); break; case EArrowType.LEFT: childRect.anchoredPosition = new Vector2(childRect.sizeDelta.x / 2f, 0f); childRect.anchorMin = new Vector2(0f, .5f); childRect.anchorMax = new Vector2(0f, .5f); childRect.rotation = Quaternion.Euler(mainRect.rotation.x, mainRect.rotation.y, mainRect.rotation.z + 180f); break; case EArrowType.RIGHT: childRect.anchoredPosition = new Vector2(-childRect.sizeDelta.x / 2f, 0f); childRect.anchorMin = new Vector2(1f, .5f); childRect.anchorMax = new Vector2(1f, .5f); childRect.rotation = Quaternion.Euler(mainRect.rotation.x, mainRect.rotation.y, mainRect.rotation.z); break; } }
public void SetLabel(PeMap.ILabel label, EArrowType arrow_type) { //m_ArrowType = arrow_type; trackLabel = label; }