//----------------------------------------------------------------------------------------------------------------------

        bool DrawCacheSettings(SceneCachePlayer t)
        {
            bool     changed   = false;
            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle = FontStyle.Bold;

            t.foldCacheSettings = EditorGUILayout.Foldout(t.foldCacheSettings, "Player", true, styleFold);
            if (t.foldCacheSettings)
            {
                //Show Selector GUI. Check if we should reopen
                string fullPath           = t.GetSceneCacheFilePath();
                string prevNormalizedPath = AssetEditorUtility.NormalizePath(fullPath);

                string newNormalizedPath = EditorGUIDrawerUtility.DrawFileSelectorGUI("Cache File Path", "MeshSync",
                                                                                      prevNormalizedPath, "sc", OnSceneCacheFileReload);
                newNormalizedPath = AssetEditorUtility.NormalizePath(newNormalizedPath);

                if (newNormalizedPath != prevNormalizedPath)
                {
                    ChangeSceneCacheFileInInspector(t, newNormalizedPath);
                }

                if (!string.IsNullOrEmpty(fullPath) && !fullPath.StartsWith(Application.streamingAssetsPath))
                {
                    GUILayout.BeginHorizontal();
                    const float BUTTON_WIDTH = 50.0f;
                    if (GUILayout.Button("Copy", GUILayout.Width(BUTTON_WIDTH)))
                    {
                        string dstPath = Misc.CopyFileToStreamingAssets(fullPath);
                        ChangeSceneCacheFileInInspector(t, dstPath);
                    }
                    GUILayout.Label("Scene Cache file to StreamingAssets");
                    EditorGUILayout.LabelField("(RECOMMENDED)", EditorStyles.boldLabel);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                }
                EditorGUILayout.Space();

                //Time Unit
                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Time Unit",
                                                                  guiFunc: () => (SceneCachePlayer.TimeUnit)EditorGUILayout.Popup("Time Unit",
                                                                                                                                  (int)t.GetTimeUnit(), TIME_UNIT_ENUMS),
                                                                  updateFunc: (SceneCachePlayer.TimeUnit timeUnit) => {
                    t.SetTimeUnit(timeUnit);
                    t.ResetTimeAnimation();
                }
                                                                  );


                SceneCachePlayer.TimeUnit selectedTimeUnit = t.GetTimeUnit();

                if (selectedTimeUnit == SceneCachePlayer.TimeUnit.Seconds)
                {
                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Time",
                                                                      guiFunc: () => (EditorGUILayout.FloatField("Time", t.GetTime())),
                                                                      updateFunc: (float time) => { t.SetTime(time); });

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Interpolation",
                                                                      guiFunc: () => (EditorGUILayout.Toggle("Interpolation", t.GetInterpolation())),
                                                                      updateFunc: (bool toggle) => { t.SetInterpolation(toggle); });
                }
                else if (selectedTimeUnit == SceneCachePlayer.TimeUnit.Frames)
                {
                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Base Frame",
                                                                      guiFunc: () => ((SceneCachePlayer.BaseFrame)EditorGUILayout.Popup("Base Frame", (int)t.GetBaseFrame(), BASE_FRAME_ENUMS)),
                                                                      updateFunc: (SceneCachePlayer.BaseFrame baseFrame) => {
                        t.SetBaseFrame(baseFrame);
                        t.ResetTimeAnimation();
                    });

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Frame",
                                                                      guiFunc: () => (EditorGUILayout.IntField("Frame", t.GetFrame())),
                                                                      updateFunc: (int frame) => { t.SetFrame(frame); });
                }

                // preload
                {
                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Preload",
                                                                      guiFunc: () => (EditorGUILayout.IntSlider("Preload Length", t.GetPreloadLength(), 0, t.frameCount)),
                                                                      updateFunc: (int preloadLength) => { t.SetPreloadLength(preloadLength); });
                }

                EditorGUILayout.Space();
            }

            return(changed);
        }
Beispiel #2
0
//----------------------------------------------------------------------------------------------------------------------
        private static bool DrawPlaybackMode(SceneCachePlayer t)
        {
            t.ShowPlaybackInInspector(EditorGUILayout.Foldout(t.IsPlaybackInInspectorShown(), "Playback", true, GetDefaultFoldoutStyle()));
            if (!t.IsPlaybackInInspectorShown())
            {
                return(false);
            }

            bool changed = false;

            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Playback Mode",
                                                              guiFunc: () =>
                                                              (SceneCachePlaybackMode)EditorGUILayout.EnumPopup("Playback Mode", t.GetPlaybackMode()),
                                                              updateFunc: (SceneCachePlaybackMode mode) => {
                t.SetPlaybackMode(mode);
                SceneCachePlayerEditorUtility.RefreshSceneCache(t);
            }
                                                              );

            ++EditorGUI.indentLevel;
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Time",
                                                              guiFunc: () => (EditorGUILayout.FloatField("Time", t.GetTime())),
                                                              updateFunc: (float time) => { t.SetTime(Mathf.Max(0, time)); });

            using (new EditorGUI.DisabledScope(t.GetPlaybackMode() == SceneCachePlaybackMode.Interpolate)) {
                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Frame",
                                                                  guiFunc: () => (EditorGUILayout.IntField("Frame", t.GetFrame())),
                                                                  updateFunc: (int frame) => { t.SetTimeByFrame(Mathf.Max(0, frame)); });
            }
            --EditorGUI.indentLevel;

            using (new EditorGUI.DisabledScope(t.GetPlaybackMode() == SceneCachePlaybackMode.Interpolate)) {
                changed |= SceneCachePlayerEditorUtility.DrawLimitedAnimationGUI(t.GetLimitedAnimationController(), t, t);
            }

            EditorGUILayout.Space();

            return(changed);
        }