示例#1
0
 void DestroyAlignmentToken()
 {
     if (AlignmentToken)
     {
         Object.Destroy(AlignmentToken.gameObject);
         AlignmentToken = null;
     }
 }
示例#2
0
    void CreateAlignmentToken()
    {
        GameObject tokenObj = Instantiate(AlignmentTokenPrefab);

        tokenObj.transform.SetParent(transform);
        tokenObj.transform.localScale    = Vector3.one;
        tokenObj.transform.localPosition = Vector3.zero;

        RectTransform parentRect = gameObject.GetComponent <RectTransform>();
        RectTransform tokenRect  = tokenObj.GetComponent <RectTransform>();

        tokenRect.anchoredPosition = new Vector2(parentRect.rect.xMin + (tokenRect.rect.width / 2f), parentRect.rect.yMin + (tokenRect.rect.height / 2f));

        AlignmentToken = tokenObj.GetComponent <AlignmentToken>();
    }