Ejemplo n.º 1
0
 /// <summary>
 /// 初始化组件
 /// </summary>
 private void InitWidgets()
 {
     if (null == m_helpData)
     {
         m_helpData = new GuideShowHelpData();
     }
     m_helpData.GuideRoot    = m_trans_Constraint;
     m_helpData.PointBoxRoot = m_trans_ConstraintPointBox;
     m_helpData.AttachRoot   = m_trans_ConstraintAttachRoot;
     if (null != m_trans_ConstraintDirection)
     {
         Transform dir = null;
         for (GuideDefine.GuideStyle j = GuideDefine.GuideStyle.Center; j < GuideDefine.GuideStyle.Down; j++)
         {
             dir = m_trans_ConstraintDirection.Find(j.ToString());
             if (null != dir)
             {
                 m_helpData.StyleRoot.Add(j, dir);
             }
         }
     }
     m_float_animAddMaxTime = (float)Mathf.Max(GuideManager.GuideShowSkipDelay, GuideManager.GuideAutoCloseDelay);
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 获取引导样式数据
    /// </summary>
    /// <param name="localData"></param>
    /// <returns></returns>
    public static GuideStyleData GetGuideStyleData(GuideShowHelpData helpData)
    {
        GuideStyleData styleData = new GuideStyleData();
        Vector3        targetPos = Vector3.zero;

        GuideDefine.LocalGuideData localData = helpData.LocalData;
        if (null == helpData.GuideRoot)
        {
            return(styleData);
        }
        Matrix4x4 localMatrix = helpData.GuideRoot.worldToLocalMatrix;

        Bounds bounds = localData.GuideTargetObjWorldBounds;
        float  offset = GuideManager.GuidePointAtOffset;
        //转化为本地坐标
        Vector3 min = localMatrix.MultiplyPoint3x4(bounds.min);
        Vector3 max = localMatrix.MultiplyPoint3x4(bounds.max);

        bounds = new Bounds(min, Vector3.zero);
        bounds.Encapsulate(max);
        if (helpData.StyleRoot.ContainsKey(localData.GStyle))
        {
            switch (localData.GStyle)
            {
            case GuideDefine.GuideStyle.LeftUp:
                styleData.ArrowRotateAngle = 0;
                styleData.ArrowRight       = false;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.min.y - offset;
                break;

            case GuideDefine.GuideStyle.Up:
                styleData.ArrowRotateAngle = 0;
                styleData.ArrowRight       = false;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.min.y - offset;
                break;

            case GuideDefine.GuideStyle.RightUp:
                styleData.ArrowRotateAngle = 0;
                styleData.ArrowRight       = true;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.min.y - offset;
                break;

            case GuideDefine.GuideStyle.Down:
                styleData.ArrowRight       = false;
                styleData.ArrowRotateAngle = -180;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.max.y + offset;
                break;

            case GuideDefine.GuideStyle.LeftDown:
                styleData.ArrowRight       = false;
                styleData.ArrowRotateAngle = -180;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.max.y + offset;
                break;

            case GuideDefine.GuideStyle.RightDown:
                styleData.ArrowRight       = true;
                styleData.ArrowRotateAngle = -180;
                targetPos.x = (bounds.max.x + bounds.min.x) / 2f;
                targetPos.y = bounds.max.y + offset;
                break;

            case GuideDefine.GuideStyle.Left:
                styleData.ArrowRight       = false;
                styleData.ArrowRotateAngle = -270;
                targetPos.x = bounds.max.x + offset;
                targetPos.y = (bounds.max.y + bounds.min.y) / 2f;
                break;

            case GuideDefine.GuideStyle.Right:
                styleData.ArrowRight       = true;
                styleData.ArrowRotateAngle = -90;
                targetPos.y = (bounds.max.y + bounds.min.y) / 2f;
                break;
            }
            styleData.TargetRoot = helpData.StyleRoot[localData.GStyle];
            styleData.TargetPos  = targetPos;
        }
        return(styleData);
    }