Пример #1
0
        public override void OnInspectorGUI()
        {
            GUI.skin.label.richText = true;
            CheckTarget();
            bool dirty = false;

            GUILayout.Space(10);
            ECurveType tp = (ECurveType)EditorGUILayout.EnumPopup(mPath.m_Type);

            if (tp != mPath.m_Type)
            {
                mPath.m_Type = tp;
                dirty        = true;
            }
            int insertAt = -1;
            int deleteAt = -1;

            mFreezeAxis = QuickGUI.MultiOptionBar(mFreezeAxis, freezeOption);
            mPointsArea = GUILayout.BeginScrollView(mPointsArea, GUILayout.MaxHeight(200));
            if (QuickGUI.DrawHeader("Sample Points", "sample points", false))
            {
                QuickGUI.BeginContents(170);
                for (int i = 1; i < caches.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    int n = QuickGUI.GroupButton(addSubBtn, GUILayout.Width(40));
                    caches[i] = EditorGUILayout.Vector3Field(string.Format("P{0}{1}", i, i == mCurrentPoint?" [Moving]":""), caches[i]);
                    EditorGUILayout.EndHorizontal();
                    if (n != -1)
                    {
                        insertAt = n == 0 ? i : -1;
                        deleteAt = n == 1 ? i : -1;
                    }
                    if (Vector3.Distance(caches[i], mPath.m_Points[i]) > snapDis)
                    {
                        dirty             = true;
                        mPath.m_Points[i] = caches[i];
                    }
                }
                if (GUILayout.Button("+", GUILayout.Width(20)))
                {
                    insertAt = caches.Length;
                    deleteAt = -1;
                }
                QuickGUI.EndContents();
            }
            GUILayout.EndScrollView();

            if (insertAt > 0)
            {
                InsertAt(insertAt);
                dirty = true;
            }
            else if (deleteAt > 0)
            {
                DeleteAt(deleteAt);
                dirty = true;
            }

            if (dirty)
            {
                caches = new Vector3[mPath.m_Points.Length];
                System.Array.Copy(mPath.m_Points, caches, caches.Length);
                mPath.RecalculateLater();
                SceneView.RepaintAll();
            }
        }