Ejemplo n.º 1
0
 void ActivatePanel(EPanel panel)
 {
     if (currentActivePanel != EPanel.None)
     {
         panels[(int)currentActivePanel].gameObject.SetActive(false);
     }
     if (panel != EPanel.None)
     {
         panels[(int)panel].gameObject.SetActive(true);
     }
     currentActivePanel = panel;
 }
Ejemplo n.º 2
0
 void ActivePanel(EPanel type)
 {
     foreach (var item in panelDic)
     {
         if (item.Key == type)
         {
             item.Value.SetActive(true);
         }
         else
         {
             item.Value.SetActive(false);
         }
     }
 }
Ejemplo n.º 3
0
    void EnablePanel(EPanel type)
    {
        foreach (KeyValuePair <EPanel, GameObject> item in _panelDic)
        {
            if (item.Value == null)
            {
                continue;
            }
            if (item.Key == type)
            {
                item.Value.SetActive(true);
            }
            else
            {
                item.Value.SetActive(false);
            }
        }

        _currentPanel = type;
    }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            CCDSolverMB cp = (CCDSolverMB)target;

            EditorGUI.BeginChangeCheck();

            EConUtil.DrawActiveLine(cp);

            //constraint target
            cp.Target = (Transform)EditorGUILayout.ObjectField("Target Object", cp.Target, typeof(Transform), true);

            EUtil.DrawSplitter();

            EUtil.PushGUIEnable(cp.IsActiveConstraint);
            {
                // reset button
                GUILayout.BeginHorizontal();
                GUILayout.Space(30f);
                if (EUtil.Button("Recollect IKConstraints", "click this when add new IK-constraint on this IK-link", Color.green))
                {
                    cp.GetSolver(true);
                    EUtil.RepaintSceneView();
                }
                GUILayout.Space(30f);
                GUILayout.EndHorizontal();


                // jointList
                if (!m_manualSetJoints)
                {
                    m_autoCollectBoneCount = EditorGUILayout.IntField(CONT_BoneCnt, m_autoCollectBoneCount);
                }
                else
                {
                    var jointList = cp.jointList;
                    Undo.RecordObject(cp, "JointList");
                    for (int i = 0; i < jointList.Count; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        jointList[i] = (Transform)EditorGUILayout.ObjectField(jointList[i], typeof(Transform), true);
                        if (GUILayout.Button(new GUIContent("+", "add new entry")))
                        {
                            jointList.Insert(i, null);
                            GUIUtility.ExitGUI();
                        }
                        if (GUILayout.Button(new GUIContent("-", "delete this entry")))
                        {
                            jointList.RemoveAt(i);
                            GUIUtility.ExitGUI();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(m_manualSetJoints ? CONT_ManualSetJoints : CONT_AutoSetJoints, EditorStyles.toolbarButton))
                {
                    m_manualSetJoints = !m_manualSetJoints;
                }

                bool isIdentical = _CheckJointListIdentical(cp);
                EUtil.PushBackgroundColor(isIdentical ? Color.white : Color.blue);
                if (GUILayout.Button(new GUIContent("Apply", "Apply the joint list"), EditorStyles.toolbarButton))
                {
                    if (m_manualSetJoints)
                    {
                        if (_CheckManualSetJointList(cp))
                        {
                            cp._RenewInitInfoAndSolver();
                        }
                    }
                    else
                    {
                        cp._RenewByCollectJointsWithBontCount(m_autoCollectBoneCount);
                    }
                    m_autoCollectBoneCount = cp.boneCount;
                }
                EUtil.PopBackgroundColor();

                EditorGUILayout.EndHorizontal();

                EUtil.DrawSplitter();

                // dist thres
                EditorGUI.BeginChangeCheck();
                float newDistThres = EditorGUILayout.FloatField(CONT_DistThres, cp.distThres);
                if (EditorGUI.EndChangeCheck())
                {
                    if (newDistThres > 0f)
                    {
                        Undo.RecordObject(cp, "Set Dist Thres");
                        cp.distThres = newDistThres;
                    }
                }

                cp.useDamp = EditorGUILayout.Toggle(CONT_Damp, cp.useDamp);
                if (cp.useDamp)
                {
                    cp.globalDamp = EditorGUILayout.FloatField("Global damp", cp.globalDamp);
                }

                cp.useTargetRotation = EditorGUILayout.Toggle(CONT_UseTargetRotation, cp.useTargetRotation);
                cp.maxIteration      = EditorGUILayout.IntField(CONT_MaxIteration, cp.maxIteration);

                cp.revertOpt = (CCDSolver.RevertOption)EditorGUILayout.EnumPopup(CONT_RevertOpt, cp.revertOpt);

                m_markerSize.val = Mathf.Max(0, EditorGUILayout.FloatField(CONT_BoneMarkSize, m_markerSize.val));

                EUtil.PushGUIEnable(!cp.Target);
                {
                    if (GUILayout.Button("Control Mode:  " + (cp.Target ? "Target" : m_panel.ToString()), EditorStyles.toolbarButton))
                    {
                        m_panel = (EPanel)((int)(m_panel + 1) % (int)EPanel.END);
                        cp.GetSolver().Target = cp.transform.position;
                    }
                    _OnGUI_IKPanel(cp);
                }
                EUtil.PopGUIEnable();

                // influence
                GUILayout.Space(5f);
                cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}");

                //initInfos
                if (Pref.ShowInitInfos)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_initInfos"), true);
                }
            }
            EUtil.PopGUIEnable();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode
            }
        }
Ejemplo n.º 5
0
        void OnSceneGUI()
        {
            CCDSolverMB cp     = (CCDSolverMB)target;
            CCDSolver   solver = cp.GetSolver();

            if (solver == null || solver.Count < 1)
            {
                return;
            }

            if (cp.ShowGizmos)
            {
                var joints = solver.GetJoints();

                Camera    sceneCam = EUtil.GetSceneViewCamera();
                Transform camTr    = sceneCam.transform;

                EUtil.PushHandleColor(Pref.IKBoneLinkColor);
                //1. draw bone line
                for (int i = 0; i < joints.Length - 1; ++i)
                {
                    var p0 = joints[i].position;
                    var p1 = joints[i + 1].position;
                    Handles.DrawAAPolyLine(3f, p0, p1);
                    Handles.DotCap(0, p0, camTr.rotation, m_markerSize.val);
                }
                if (joints.Length > 0)
                {
                    Handles.DotCap(0, joints.Last().position, camTr.rotation, m_markerSize.val);
                }
                EUtil.PopHandleColor();

                //1.5 draw line from end-joint to target pos
                {
                    var p0 = joints.Last().position;
                    var p1 = solver.Target;
                    Handles.DrawDottedLine(p0, p1, 5f);
                }

                //2. call each constraint's OnSceneGUI
                for (int i = 0; i < joints.Length - 1; ++i)
                {
                    var cons = solver.GetConstraint(i);

                    foreach (var con in cons)
                    {
                        if (!con || !con.enabled)
                        {
                            continue;
                        }

                        Editor      e    = EUtil.GetEditor(con);
                        IOnSceneGUI igui = e as IOnSceneGUI;
                        if (igui != null)
                        {
                            igui.OnSceneGUI();
                        }
                    }
                }
            }

            //3. debug draw
            if (!cp.Target)
            {
                if (m_panel != EPanel.Normal)
                {
                    Tools.current = Tool.None;

                    // move handle
                    if (m_panel == EPanel.Continuous)
                    {
                        EditorGUI.BeginChangeCheck();
                    }

                    solver.Target = Handles.PositionHandle(solver.Target, Quaternion.identity);

                    if (m_panel == EPanel.Continuous && EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObjects(solver.GetJoints(), "IK execute");
                        solver.Execute();
                    }

                    // hotkeys
                    Event e = Event.current;
                    if (e.type == EventType.KeyUp && Tools.viewTool != ViewTool.FPS)
                    {
                        if (e.keyCode == KeyCode.E)
                        {
                            Tools.current = Tool.Rotate; m_panel = EPanel.Normal;
                        }
                        else if (e.keyCode == KeyCode.R)
                        {
                            Tools.current = Tool.Scale; m_panel = EPanel.Normal;
                        }
                        else if (e.keyCode == KeyCode.Q)
                        {
                            Tools.current = Tool.View; m_panel = EPanel.Normal;
                        }
                    }
                }
            }
        }
        /// <summary>
        ///     逐个显示
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="img"></param>
        public static void DisPlayListItem(LiuXingData tag, Image img)
        {
            if (tag == null) return;
            // 磁贴方块
            var cellpal = new EPanel
                {
                    Size = new Size(406, 210),
                    BackColor = Color.White,
                    Tag = tag
                };
            PublicStatic.LiuXingCon.Controls.Add(cellpal);

            if (!string.IsNullOrEmpty(tag.Cos))
            {
                new HDarge(
                    cellpal,
                    tag.Cos,
                    new Font(PublicStatic.SegoeFont, 12F),
                    new Size(40, 25),
                    new Point(-2, 44 + 24 + 45 + 25 + 20 - 135),
                    Color.FromArgb(248, 248, 248), Color.FromArgb(0, 122, 204),
                    ContentAlignment.MiddleCenter, AnchorStyles.Top
                    );
            }
            // 方块内海报
            if (img != null)
            {
                var cellimg = new EPicBox
                    {
                        Size = new Size(150, 210),
                        BackColor = Color.White,
                        Image = img,
                        SizeMode = PictureBoxSizeMode.StretchImage
                    };
                cellpal.Controls.Add(cellimg);
            }
            // 方块内文字
            string tempname = tag.Name;
            if (!string.IsNullOrEmpty(tempname))
            {
                if (tempname.Contains("/"))
                {
                    tempname = tempname.Split("/".ToCharArray())[0];
                }
                new HDarge(
                    cellpal,
                    tempname,
                    new Font(PublicStatic.SegoeFont, 22F),
                    new Size(244, 42),
                    new Point(150, 10),
                    Color.FromArgb(0, 122, 204), Color.Transparent,
                    ContentAlignment.BottomCenter, AnchorStyles.Top
                    );
            }
            new HDarge(
                cellpal,
                "",
                new Font(PublicStatic.SegoeFont, 14F),
                new Size(240, 1),
                new Point(150 + 8, 48 + 10),
                Color.Transparent, Color.FromArgb(90, 122, 204),
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );
            new HDarge(
                cellpal,
                "主演:" + tag.Car,
                new Font(PublicStatic.SegoeFont, 12F),
                new Size(248, 45),
                new Point(150 + 6, 44 + 24),
                Color.FromArgb(60, 60, 60), Color.Transparent,
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );
            new HDarge(
                cellpal,
                "年代:" + tag.Tim,
                new Font(PublicStatic.SegoeFont, 12F),
                new Size(120, 25),
                new Point(150 + 6, 44 + 24 + 45),
                Color.FromArgb(60, 60, 60), Color.Transparent,
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );
            new HDarge(
                cellpal,
                "地区:" + tag.Loc,
                new Font(PublicStatic.SegoeFont, 12F),
                new Size(120, 25),
                new Point(150 + 6 + 120, 44 + 24 + 45),
                Color.FromArgb(60, 60, 60), Color.Transparent,
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );
            new HDarge(
                cellpal,
                "类型:" + tag.Typ,
                new Font(PublicStatic.SegoeFont, 12F),
                new Size(120, 25),
                new Point(150 + 6, 44 + 24 + 45 + 25),
                Color.FromArgb(60, 60, 60), Color.Transparent,
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );
            new HDarge(
                cellpal,
                "更新:" + tag.Upt,
                new Font(PublicStatic.SegoeFont, 12F),
                new Size(120, 25),
                new Point(150 + 6 + 120, 44 + 24 + 45 + 25),
                Color.FromArgb(60, 60, 60), Color.Transparent,
                ContentAlignment.MiddleLeft, AnchorStyles.Top
                );

            // 方块内按钮
            string temphds = tag.HDs;
            if (string.IsNullOrEmpty(temphds)) return;
            var playbtn = new LButton
                (
                cellpal,
                1,
                temphds,
                new Font(PublicStatic.SegoeFont, 12.5F),
                new Size(101, 32),
                new Point(150 + 152, 40 + 25*5 + 2*5),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(248, 248, 248),
                Color.FromArgb(248, 248, 248),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(248, 248, 248),
                AnchorStyles.Top
                );
            var copybtn = new LButton
                (
                cellpal,
                1,
                "复制链接",
                new Font(PublicStatic.SegoeFont, 12.5F),
                new Size(101, 32),
                new Point(150 + 152 - 101 - 8, 40 + 25*5 + 2*5),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(248, 248, 248),
                Color.FromArgb(248, 248, 248),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(0, 122, 204),
                Color.FromArgb(248, 248, 248),
                AnchorStyles.Top
                );
            copybtn.MouseClick += Copybtn_MouseClick;
            playbtn.MouseClick += Playbtn_MouseClick;

            if (string.IsNullOrEmpty(PublicStatic.SearchBox.Text))
            {
                PublicStatic.LiuXingCon.Focus();
            }
        }