Example #1
0
 public void SetC_Line()
 {
     if (cLine == null)
     {
         cLine = transform.GetComponentInChildren <C_Line>(true);
     }
     cLine.startTran = cornerTran;
     cLine.endTran   = target;
     cLine.color     = color;
 }
Example #2
0
        /// 根据相对位置设置corner
        public void UpdatePosAndLine()
        {
            if (cLine == null)
            {
                cLine = transform.GetComponentInChildren <C_Line>();
            }
            SetLineCorner(Corner.右中);
            float rightDistance = (cornerTran.position - target.position).magnitude;

            SetLineCorner(Corner.左中);
            float leftDistance = (cornerTran.position - target.position).magnitude;

            Vector3 tranPos   = transform.position;
            Vector3 targetPos = target.position;

            if (leftDistance - rightDistance > widthChangeStep)
            {
                if (tranPos.y - targetPos.y < -heightChangeStep)
                {
                    SetLine(true, Corner.右上);
                }
                else
                {
                    SetLine(true, Corner.右下);
                }
            }
            else if (rightDistance - leftDistance > widthChangeStep)
            {
                if (tranPos.y - targetPos.y < -heightChangeStep)
                {
                    SetLine(true, Corner.左上);
                }
                else
                {
                    SetLine(true, Corner.左下);
                }
            }
            else
            {
                if (tranPos.y - targetPos.y < -heightChangeStep)
                {
                    SetLine(true, Corner.);
                }
                else
                {
                    SetLine(true, Corner.);
                }
            }
        }
Example #3
0
        private void Awake()
        {
            cLine           = transform.GetComponentInChildren <C_Line>(true);
            cLine.startTran = cornerTran;
            SetLine(true, Corner.左中);
            offset = transform.position - target.position;
            C_Line cline = GetComponentInChildren <C_Line>();

            if (cline != null)
            {
                cline.endTran = target;
            }
            if (is连接在一个新生成的物体上)
            {
                transform.GetChild(2).gameObject.SetActive(false);
            }
        }