Example #1
0
        public static void Ruler(float startTime, float endTime)
        {
            using (new EditorGUI.DisabledScope(true)) GUILayout.Button("", EditorStyles.toolbarButton);
            var rect = GUILayoutUtility.GetLastRect();//既存のGUILayoutを実行しRectだけ盗む

            EclairGUILayout.Ruler(rect, startTime, endTime);
        }
Example #2
0
        public static void Ruler(float startTime, float endTime, params GUILayoutOption[] options)
        {
            using (new EditorGUI.DisabledScope(true)) GUILayout.Button("", EditorStyles.toolbarButton, options);
            //EditorGUILayout.LabelField("", "", EditorStyles.toolbar, options);
            var rect = GUILayoutUtility.GetLastRect();//既存のGUILayoutを実行しRectだけ盗む

            EclairGUILayout.Ruler(rect, startTime, endTime);
        }
Example #3
0
        void OnGUI()
        {
            using (var horizontalScope = new EditorGUILayout.HorizontalScope("toolbar"))
            {
                tab = GUILayout.Toolbar(tab, new string[] { "Timeline", "Raw" }, EditorStyles.toolbarButton, GUILayout.Width(180));
                //GUILayout.Space(20);
                toolbarSpace();//こうしないとRawボタンの右側の線が表示されない
                using (new EditorGUI.DisabledScope(true)) GUILayout.Button("Play", EditorStyles.toolbarButton, GUILayout.Width(64));
                EditorGUILayout.Space();
                GUIStyle rightLabelStyle = new GUIStyle(GUI.skin.label);
                rightLabelStyle.alignment        = TextAnchor.MiddleRight;
                rightLabelStyle.normal.textColor = new Color(.5f, .5f, .5f, 1);
                EditorGUILayout.LabelField(sceneName, rightLabelStyle);
            }

            if (!isEditable)
            {
                GUIStyle centerLabelStyle = new GUIStyle(GUI.skin.label);
                centerLabelStyle.alignment = TextAnchor.MiddleCenter;
                //centerLabelStyle.normal.textColor = new Color (0, 0, 0,1 );
                EditorGUILayout.LabelField(MessageWhenUnEditable, centerLabelStyle, GUILayout.Height(128));
                return;
            }


            if (tab == 0)//Timelineタブ
            {
                var horizontalScrollbarRect = new Rect(paneWidth - 1, position.height - 15, position.width - paneWidth + 1 - 30, 15);
                var zoomInButtonRect        = new Rect(position.width - 30, position.height - 15, 15, 15);
                var zoomOutButtonRect       = new Rect(position.width - 15, position.height - 15, 15, 15);
                timelineScrollPos.x = GUI.HorizontalScrollbar(horizontalScrollbarRect, timelineScrollPos.x, timelineZoomFactor, -0.2f, timelineTimeMax);
                if (GUI.Button(zoomInButtonRect, "+", "OL Plus"))
                {
                    timelineZoomFactor -= 1.0f;
                }
                if (GUI.Button(zoomOutButtonRect, "-", "OL Minus"))
                {
                    timelineZoomFactor += 1.0f;
                }

                float startTime = timelineScrollPos.x;
                float endTime   = timelineScrollPos.x + timelineZoomFactor;

                using (var rulerScope = new EditorGUILayout.HorizontalScope("toolbar"))
                {
                    GUILayout.Button("Add", EditorStyles.toolbarButton, GUILayout.Width(64));
                    toolbarSpace(paneWidth - 64 - 6);
                    //ここまで256px
                    EclairGUILayout.Ruler(startTime, endTime);
                }

                //グリッド
                var timelineBackGroundRect = new Rect(paneWidth - 1, 36, position.width - paneWidth - 6 + 1, position.height - 36 - 15);
                EclairGUILayout.TimelineBackground(timelineBackGroundRect, startTime, endTime);
                //横スクロールでスクロール
                Event evt = Event.current;
                if (evt.type.Equals(EventType.ScrollWheel))
                {
                    if (evt.shift)
                    {
                        timelineZoomFactor += (evt.delta.x + evt.delta.y) / 4;
                        Repaint();
                    }
                    else
                    {
                        timelineScrollPos.x += (evt.delta.x + evt.delta.y) * timelineZoomFactor / 24;
                        Repaint();
                    }
                }


                //Cueの削除
                if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Delete || Event.current.keyCode == KeyCode.Backspace))
                {
                    //Debug.Log ("aahahahahahhhahaa");
                    Undo.RecordObject(cueScene, "Delete Cue");
                    foreach (string ID in selectedCueList)
                    {
                        //Debug.Log (ID);
                        var cue = cueScene.cueList.FindIndex(x => x.UUID == ID);
                        Debug.Log(cue);
                        cueScene.cueList.RemoveAt(cue);
                    }
                }

                cueListSerialized.serializedObject.Update();

                var absoluteCueList = CueListUtil.GenerateAbsoluteCueList(cueListSerialized);

                //CueIconのドラッグ
                if (EclairGUILayout.isCueIconDragging)
                {
                    float delta = (Event.current.mousePosition.x - cueIconDragStartedMousePos.x) * getTimePerPixel(timelineBackGroundRect.width, timelineZoomFactor);
                    foreach (string ID in selectedCueList)
                    {
                        var acue  = absoluteCueList.Find(x => x.Value.FindPropertyRelative("UUID").stringValue == ID);
                        int index = absoluteCueList.IndexOf(acue);
                        absoluteCueList.Remove(acue);
                        absoluteCueList.Insert(index, new KeyValuePair <float, SerializedProperty>((int)((acue.Key + delta + timelineSnapSpan / 2) / timelineSnapSpan) * timelineSnapSpan, acue.Value));
                    }
                }

                //タイムライントラック描画
                List <string> trackList = new List <string>();
                foreach (var acue in absoluteCueList)
                {
                    bool   isSelectionChanged = false;
                    string gameObjectName     = acue.Value.FindPropertyRelative("gameObjectName").stringValue;
                    if (!trackList.Exists(st => st == gameObjectName))
                    {
                        trackList.Add(gameObjectName);
                        var selectedCueListTemp = EclairGUILayout.TimelineTrack(absoluteCueList, gameObjectName, paneWidth, (trackList.Count % 2) > 0, startTime, endTime, selectedCueList);
                        if (selectedCueListTemp.Equals(selectedCueList))
                        {
                            selectedCueList    = selectedCueListTemp;
                            isSelectionChanged = true;
                        }
                    }
                    if (isSelectionChanged)
                    {
                        Repaint();
                    }
                    else
                    {
                        if (Event.current.type == EventType.MouseUp)
                        {
                            //Debug.Log("weiwei");
                            Rect rect = new Rect(0, 0, paneWidth, position.height);
                            if (rect.Contains(Event.current.mousePosition))
                            {
                                selectedCueList.Clear();
                                Repaint();
                            }
                        }
                    }
                }

                if (Event.current.type == EventType.MouseUp)
                {
                    if (EclairGUILayout.isCueIconDragging)
                    {
                        EclairGUILayout.isCueIconDragging = false;
                        EclairGUILayout.CueIconDragEnd();
                    }
                }

                if (dragEndFlag)
                {
                    dragEndFlag = false;
                    Undo.RecordObject(cueScene, "Edit CueScene");
                    cueScene.cueList = CueListUtil.GenerateCueListFromAbsolute(absoluteCueList);
                    //cueListSerialized = new SerializedObject(cueScene).FindProperty("cueList");
                    cueListSerialized.serializedObject.ApplyModifiedProperties();
                }
            }


            else//Rawタブ
            {
                cueListSerialized.serializedObject.Update();
                // リスト・配列の変更可能なリストの表示
                using (var scrollView = new EditorGUILayout.ScrollViewScope(rawScrollPos)) {
                    rawScrollPos = scrollView.scrollPosition;
                    rawList.DoLayoutList();
                }
                cueListSerialized.serializedObject.ApplyModifiedProperties();
            }
        }