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

        public void DrawServerSettings(MeshSyncServer t)
        {
            var styleFold = EditorStyles.foldout;

            styleFold.fontStyle = FontStyle.Bold;

            bool   isServerStarted = m_meshSyncServer.IsServerStarted();
            string serverStatus    = isServerStarted ? "Server (Status: Started)" : "Server (Status: Stopped)";

            t.foldServerSettings = EditorGUILayout.Foldout(t.foldServerSettings, serverStatus, true, styleFold);
            if (t.foldServerSettings)
            {
                bool autoStart = EditorGUILayout.Toggle("Auto Start", m_meshSyncServer.IsAutoStart());
                m_meshSyncServer.SetAutoStartServer(autoStart);

                //Draw GUI that are disabled when autoStart is true
                EditorGUI.BeginDisabledGroup(autoStart);
                int serverPort = EditorGUILayout.IntField("Server Port:", (int)m_meshSyncServer.GetServerPort());
                m_meshSyncServer.SetServerPort((ushort)serverPort);
                GUILayout.BeginHorizontal();
                if (isServerStarted)
                {
                    if (GUILayout.Button("Stop", GUILayout.Width(110.0f)))
                    {
                        m_meshSyncServer.StopServer();
                    }
                }
                else
                {
                    if (GUILayout.Button("Start", GUILayout.Width(110.0f)))
                    {
                        m_meshSyncServer.StartServer();
                    }
                }
                GUILayout.EndHorizontal();
                EditorGUI.EndDisabledGroup();

                string prevFolder     = t.GetAssetsFolder();
                string selectedFolder = AssetEditorUtility.NormalizePath(
                    EditorGUIDrawerUtility.DrawFolderSelectorGUI("Asset Dir", "Asset Dir", prevFolder, null)
                    );
                if (selectedFolder != prevFolder)
                {
                    if (string.IsNullOrEmpty(selectedFolder) || !AssetEditorUtility.IsPathNormalized(selectedFolder))
                    {
                        Debug.LogError($"[MeshSync] {selectedFolder} is not under Assets. Ignoring.");
                    }
                    else
                    {
                        t.SetAssetsFolder(selectedFolder);
                    }
                }

                Transform rootObject = (Transform)EditorGUILayout.ObjectField("Root Object", t.GetRootObject(),
                                                                              typeof(Transform), allowSceneObjects: true);
                t.SetRootObject(rootObject);

                EditorGUILayout.Space();
            }
        }
Exemplo n.º 2
0
        protected static bool DrawMiscSettings(BaseMeshSync t)
        {
            bool changed = false;
            MeshSyncPlayerConfig playerConfig = t.GetConfigV();

            // Misc
            t.foldMisc = EditorGUILayout.Foldout(t.foldMisc, "Misc", true, GetBoldFoldoutStyle());
            if (t.foldMisc)
            {
                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Material List",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Sync Material List", playerConfig.SyncMaterialList),
                                                                  updateFunc: (bool toggle) => { playerConfig.SyncMaterialList = toggle; }
                                                                  );

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Progressive Display",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Progressive Display", playerConfig.ProgressiveDisplay),
                                                                  updateFunc: (bool toggle) => { playerConfig.ProgressiveDisplay = toggle; }
                                                                  );


                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Logging",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Logging", playerConfig.Logging),
                                                                  updateFunc: (bool toggle) => { playerConfig.Logging = toggle; }
                                                                  );

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Profiling",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Profiling", playerConfig.Profiling),
                                                                  updateFunc: (bool toggle) => { playerConfig.Profiling = toggle; }
                                                                  );

                EditorGUILayout.Space();
            }

            return(changed);
        }
    internal static void DrawModelImporterSettingsGUI(Object obj, ModelImporterSettings settings) {
        EditorGUIDrawerUtility.DrawUndoableGUI(obj, "Create Materials",            
            guiFunc: () => (bool)EditorGUILayout.Toggle("Create Materials", settings.CreateMaterials), 
            updateFunc: (bool createMat) => { settings.CreateMaterials = createMat; });


        DrawModelImporterMaterialSearchMode(obj, settings);
    }
Exemplo n.º 4
0
//----------------------------------------------------------------------------------------------------------------------

        protected static bool DrawAssetSyncSettings(BaseMeshSync t)
        {
            t.foldSyncSettings = EditorGUILayout.Foldout(t.foldSyncSettings, "Asset Sync Settings", true, GetBoldFoldoutStyle());
            MeshSyncPlayerConfig config = t.GetConfigV();

            if (!t.foldSyncSettings)
            {
                return(false);
            }

            bool changed = false;

            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Transform",
                                                              guiFunc: () => EditorGUILayout.Toggle("Update Transform", config.SyncTransform),
                                                              updateFunc: (bool toggle) => { config.SyncTransform = toggle; }
                                                              );

            ComponentSyncSettings syncCameraSettings = config.GetComponentSyncSettings(MeshSyncPlayerConfig.SYNC_CAMERA);

            changed |= MeshSyncInspectorUtility.DrawComponentSyncSettings(t, "Cameras", syncCameraSettings);

            using (new EditorGUI.DisabledScope(!(syncCameraSettings.CanCreate && syncCameraSettings.CanUpdate))) {
                EditorGUI.indentLevel++;

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Physical Camera Params",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Use Physical Params", config.IsPhysicalCameraParamsUsed()),
                                                                  updateFunc: (bool toggle) => { config.UsePhysicalCameraParams(toggle); }
                                                                  );

                EditorGUI.indentLevel--;
            }

            changed |= MeshSyncInspectorUtility.DrawComponentSyncSettings(t, "Lights",
                                                                          config.GetComponentSyncSettings(MeshSyncPlayerConfig.SYNC_LIGHTS));


            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Meshes",
                                                              guiFunc: () => EditorGUILayout.Toggle("Meshes", config.SyncMeshes),
                                                              updateFunc: (bool toggle) => { config.SyncMeshes = toggle; }
                                                              );

            EditorGUI.indentLevel++;
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Update Mesh Colliders",
                                                              guiFunc: () => EditorGUILayout.Toggle("Update Mesh Colliders", config.UpdateMeshColliders),
                                                              updateFunc: (bool toggle) => { config.UpdateMeshColliders = toggle; }
                                                              );
            EditorGUI.indentLevel--;

            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Visibility",
                                                              guiFunc: () => EditorGUILayout.Toggle("Visibility", config.SyncVisibility),
                                                              updateFunc: (bool toggle) => { config.SyncVisibility = toggle; }
                                                              );

            EditorGUILayout.Space();

            return(changed);
        }
 internal static void DrawModelImporterMaterialSearchMode(Object obj, ModelImporterSettings settings) {
     using (new EditorGUI.DisabledScope(!settings.CreateMaterials)) {
         
         EditorGUIDrawerUtility.DrawUndoableGUI(obj, "Search Mode",            
             guiFunc: () => {
                 ++EditorGUI.indentLevel;
                 AssetSearchMode ret = (AssetSearchMode)EditorGUILayout.EnumPopup("Search Mode", settings.MaterialSearchMode);                    
                 --EditorGUI.indentLevel;
                 return ret;
             }, 
             updateFunc: (AssetSearchMode mode) => { settings.MaterialSearchMode = mode; });
     }
 }
Exemplo n.º 6
0
//----------------------------------------------------------------------------------------------------------------------

        bool DrawCacheFile(SceneCachePlayer t)
        {
            t.ShowCacheFileInInspector(EditorGUILayout.Foldout(t.IsCacheFileShownInInspector(), "File", true, GetDefaultFoldoutStyle()));
            if (!t.IsCacheFileShownInInspector())
            {
                return(false);
            }

            bool changed = false;

            //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();

            //[TODO-sin: 2022-3-14] This may cause crash when sliding the values back and forth. Find out why
            // preload
            {
                // changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "SceneCache: Preload",
                //     guiFunc: () => (EditorGUILayout.IntSlider("Preload Length", t.GetPreloadLength(), 0, t.frameCount)),
                //     updateFunc: (int preloadLength) => { t.SetPreloadLength(preloadLength); });
            }

            return(changed);
        }
//----------------------------------------------------------------------------------------------------------------------

    private void DrawFolderGUI() {
        string prevFolder = m_asset.GetFolder();
        string newLoadPath = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Image Sequence", "Select Folder", 
            prevFolder,
            ReloadFolder,
            AssetUtility.NormalizeAssetPath
        );        
        
        if (newLoadPath != prevFolder) {
            ImportImages(newLoadPath);
            GUIUtility.ExitGUI();
        }

    }
        protected static bool DrawImportSettings(BaseMeshSync t)
        {
            bool changed = false;
            MeshSyncPlayerConfig playerConfig = t.GetConfigV();

            t.foldImportSettings = EditorGUILayout.Foldout(t.foldImportSettings, "Import Settings", true, GetBoldFoldoutStyle());
            if (t.foldImportSettings)
            {
                MeshSyncInspectorUtility.DrawModelImporterSettingsGUI(t, playerConfig.GetModelImporterSettings());

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Animation Interpolation",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Animation Interpolation"),
                                                                                                       playerConfig.AnimationInterpolation, MeshSyncEditorConstants.ANIMATION_INTERPOLATION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.AnimationInterpolation = val; }
                                                                  );


                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Keyframe Reduction",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Keyframe Reduction", playerConfig.KeyframeReduction),
                                                                  updateFunc: (bool toggle) => { playerConfig.KeyframeReduction = toggle; }
                                                                  );

                if (playerConfig.KeyframeReduction)
                {
                    EditorGUI.indentLevel++;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Threshold",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Threshold", playerConfig.ReductionThreshold),
                                                                      updateFunc: (float val) => { playerConfig.ReductionThreshold = val; }
                                                                      );

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Erase Flat Curves",
                                                                      guiFunc: () => EditorGUILayout.Toggle("Erase Flat Curves", playerConfig.ReductionEraseFlatCurves),
                                                                      updateFunc: (bool toggle) => { playerConfig.ReductionEraseFlatCurves = toggle; }
                                                                      );
                    EditorGUI.indentLevel--;
                }

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Z-Up Correction",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Z-Up Correction"), playerConfig.ZUpCorrection,
                                                                                                       MeshSyncEditorConstants.Z_UP_CORRECTION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.ZUpCorrection = val; }
                                                                  );

                EditorGUILayout.Space();
            }

            return(changed);
        }
Exemplo n.º 9
0
//----------------------------------------------------------------------------------------------------------------------

    private void DrawFolderGUI() {
        string prevFolder = m_asset.GetFolder();
        string newLoadPath = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Image Sequence", "Select Folder", 
            prevFolder,
            ReloadFolder            
        );
        newLoadPath = AssetUtility.NormalizeAssetPath(newLoadPath); 
        
        if (newLoadPath != prevFolder) {
            Undo.RecordObject(m_asset, "Change Image Sequence Folder");            
            ImportImages(newLoadPath);
            GUIUtility.ExitGUI();
        }

    }
Exemplo n.º 10
0
        internal static bool DrawFrameMarkersGUI <T>(BaseExtendedClipPlayableAsset <T> clipDataPlayableAsset) where T : PlayableFrameClipData
        {
            T clipData = clipDataPlayableAsset.GetBoundClipData();

            if (null == clipData)
            {
                return(false);
            }

            bool showFrameMarkers = EditorGUIDrawerUtility.DrawUndoableGUI(
                clipDataPlayableAsset, "Show Frame Markers",
                /*guiFunc=*/ () => EditorGUILayout.Toggle("Show Frame Markers", clipData.AreFrameMarkersRequested()),
                /*updateFunc=*/ (bool newValue) => { clipData.RequestFrameMarkers(newValue); }
                );

            return(showFrameMarkers);
        }
Exemplo n.º 11
0
//----------------------------------------------------------------------------------------------------------------------
    
    //returns true if there is any change. False otherwise
    internal static bool DrawComponentSyncSettings(Object obj, string prefixLabel,  ComponentSyncSettings syncSettings) {
        EditorGUILayout.BeginHorizontal();
        
        EditorGUILayout.PrefixLabel(prefixLabel);
        GUILayout.Space(2);
        bool changed = EditorGUIDrawerUtility.DrawUndoableGUI(obj, "Sync: Create",            
            guiFunc: () => (bool)GUILayout.Toggle(syncSettings.CanCreate,"Create"), 
            updateFunc: (bool val) => { syncSettings.CanCreate = val; });

        using (new EditorGUI.DisabledScope(!syncSettings.CanCreate)) {
            
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(obj, "Sync: Update",            
                guiFunc: () => (bool)GUILayout.Toggle(syncSettings.CanUpdate,"Update"), 
                updateFunc: (bool val) => { syncSettings.CanUpdate = val; });
        }

        EditorGUILayout.EndHorizontal();
        return changed;

    }
Exemplo n.º 12
0
//----------------------------------------------------------------------------------------------------------------------    
    
    internal static bool DrawLimitedAnimationGUI(LimitedAnimationController ctrl, 
        Object target, SceneCachePlayer sc) 
    {
        bool         changed   = false;
        const string UNDO_TEXT = "SceneCache: Limited Animation";
        
        //Limited Animation
        changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
            guiFunc: () => (EditorGUILayout.Toggle("Limited Animation", ctrl.IsEnabled())),
            updateFunc: (bool limitedAnimation) => {
                ctrl.SetEnabled(limitedAnimation);
                SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
            });

        ++EditorGUI.indentLevel;
        using (new EditorGUI.DisabledScope(!ctrl.IsEnabled())) {
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
                guiFunc: () => (
                    EditorGUILayout.IntField("Num Frames to Hold", ctrl.GetNumFramesToHold())
                ),
                updateFunc: (int frames) => {
                    ctrl.SetNumFramesToHold(frames);
                    SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
                });
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
                guiFunc: () => (
                    EditorGUILayout.IntField("Frame Offset", ctrl.GetFrameOffset())
                ),
                updateFunc: (int offset) => {
                    ctrl.SetFrameOffset(offset);
                    SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
                });
        }

        --EditorGUI.indentLevel;

        EditorGUILayout.Space();
        return changed;
    }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
//----------------------------------------------------------------------------------------------------------------------
    public override void OnInspectorGUI() {
        if (m_scPlayableAsset.IsNullRef())
            return;
        
        SerializedObject so = serializedObject;
        EditorGUILayout.PropertyField(so.FindProperty("m_sceneCachePlayerRef"), SCENE_CACHE_PLAYER);
        
        EditorGUIDrawerUtility.DrawUndoableGUI(m_scPlayableAsset, "SceneCache: Snap",            
            guiFunc: () => {
                SnapToFrame snap = m_scPlayableAsset.GetSnapToFrame();
                return (SnapToFrame)EditorGUILayout.EnumPopup(Contents.SnapToFrame, snap);
            }, 
            updateFunc: (SnapToFrame snap) => { m_scPlayableAsset.SetSnapToFrame(snap); });
                
        {
            // Curve Operations
            GUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Curves", EditorStyles.boldLabel);

            const float BUTTON_X     = 30;
            const float BUTTON_WIDTH = 160f;
            if (DrawGUIButton(BUTTON_X, BUTTON_WIDTH,"To Linear")) {
                SceneCacheClipData clipData = m_scPlayableAsset.GetBoundClipData();
                clipData?.SetCurveToLinear();
            }
            
            if (DrawGUIButton(BUTTON_X, BUTTON_WIDTH,"Apply Original")) {
                SceneCacheClipData clipData = m_scPlayableAsset.GetBoundClipData();
                clipData?.ApplyOriginalSceneCacheCurve();                
            }
            
            GUILayout.EndVertical();                    
        }
        
        so.ApplyModifiedProperties();       
    }
Exemplo n.º 15
0
//----------------------------------------------------------------------------------------------------------------------

        protected static bool DrawAnimationTweak(BaseMeshSync player)
        {
            bool changed = false;

            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle       = FontStyle.Bold;
            player.foldAnimationTweak = EditorGUILayout.Foldout(player.foldAnimationTweak, "Animation Tweak", true, styleFold);
            if (player.foldAnimationTweak)
            {
                MeshSyncPlayerConfig   config = player.GetConfigV();
                AnimationTweakSettings animationTweakSettings = config.GetAnimationTweakSettings();

                float frameRate            = 30.0f;
                List <AnimationClip> clips = player.GetAnimationClips();
                if (clips.Count > 0)
                {
                    frameRate = clips[0].frameRate;
                }

                {
                    // Override Frame Rate
                    GUILayout.BeginVertical("Box");
                    EditorGUILayout.LabelField("Override Frame Rate", EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Frame Rate",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Frame Rate", frameRate),
                                                                      updateFunc: (float val) => {
                        if (val > 0)
                        {
                            ApplyFrameRate(clips, val);
                        }
                    }
                                                                      );
                    EditorGUI.indentLevel--;
                    GUILayout.EndVertical();
                }



                // Time Scale
                {
                    GUILayout.BeginVertical("Box");
                    EditorGUILayout.LabelField("Time Scale", EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;
                    float prevTimeScale  = animationTweakSettings.TimeScale;
                    float prevTimeOffset = animationTweakSettings.TimeOffset;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Scale",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Scale", animationTweakSettings.TimeScale),
                                                                      updateFunc: (float val) => { animationTweakSettings.TimeScale = val; }
                                                                      );


                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Offset",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Offset", animationTweakSettings.TimeOffset),
                                                                      updateFunc: (float val) => { animationTweakSettings.TimeOffset = val; }
                                                                      );
                    if (!Mathf.Approximately(prevTimeScale, animationTweakSettings.TimeScale) ||
                        !Mathf.Approximately(prevTimeOffset, animationTweakSettings.TimeOffset)
                        )
                    {
                        ApplyTimeScale(clips, animationTweakSettings.TimeScale,
                                       animationTweakSettings.TimeOffset
                                       );
                    }
                    EditorGUI.indentLevel--;
                    GUILayout.EndVertical();
                }

                // Drop Keyframes
                {
                    GUILayout.BeginVertical("Box");
                    EditorGUILayout.LabelField("Drop Keyframes", EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;
                    int prevDropStep = animationTweakSettings.DropStep;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Step",
                                                                      guiFunc: () => EditorGUILayout.IntField("Step", animationTweakSettings.DropStep),
                                                                      updateFunc: (int val) => { animationTweakSettings.DropStep = val; }
                                                                      );

                    if (prevDropStep != animationTweakSettings.DropStep && animationTweakSettings.DropStep > 1)
                    {
                        ApplyDropKeyframes(clips, animationTweakSettings.DropStep);
                    }
                    EditorGUI.indentLevel--;
                    GUILayout.EndVertical();
                }

                // Keyframe Reduction
                {
                    GUILayout.BeginVertical("Box");
                    EditorGUILayout.LabelField("Keyframe Reduction", EditorStyles.boldLabel);
                    EditorGUI.indentLevel++;
                    float prevReductionThreshold = animationTweakSettings.ReductionThreshold;
                    bool  prevEraseFlatCurves    = animationTweakSettings.EraseFlatCurves;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Threshold",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Threshold", animationTweakSettings.ReductionThreshold),
                                                                      updateFunc: (float val) => {
                        animationTweakSettings.ReductionThreshold = val;
                        ApplyKeyframeReduction(clips, val, animationTweakSettings.EraseFlatCurves);
                    }
                                                                      );

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Erase Flat Curves",
                                                                      guiFunc: () => EditorGUILayout.Toggle("Erase Flat Curves", animationTweakSettings.EraseFlatCurves),
                                                                      updateFunc: (bool toggle) => {
                        animationTweakSettings.EraseFlatCurves = toggle;
                        ApplyKeyframeReduction(clips, animationTweakSettings.ReductionThreshold, toggle);
                    }
                                                                      );

                    EditorGUI.indentLevel--;
                    GUILayout.EndVertical();
                }

                EditorGUILayout.Space();
            }

            return(changed);
        }
Exemplo n.º 16
0
//----------------------------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            //View resolution
            Vector2 res = ViewEditorUtility.GetMainGameViewSize();

            EditorGUILayout.LabelField("Resolution (Modify GameView size to change)");
            ++EditorGUI.indentLevel;
            EditorGUILayout.LabelField("Width", res.x.ToString(CultureInfo.InvariantCulture));
            EditorGUILayout.LabelField("Height", res.y.ToString(CultureInfo.InvariantCulture));
            --EditorGUI.indentLevel;
            EditorGUILayout.Space(15f);

            //Check if the asset is actually inspected
            if (null != TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset)
            {
                return;
            }

            ValidateAssetFolder();

            string prevFolder = m_asset.GetFolder();

            string newFolder = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Cache Output Folder", "Select Folder",
                                                                            prevFolder,
                                                                            null,
                                                                            AssetUtility.NormalizeAssetPath
                                                                            );

            if (newFolder != prevFolder)
            {
                m_asset.SetFolder(AssetUtility.NormalizeAssetPath(newFolder));
                GUIUtility.ExitGUI();
            }

            TimelineClipSISData timelineClipSISData = m_asset.GetBoundTimelineClipSISData();

            if (null == timelineClipSISData)
            {
                return;
            }

            GUILayout.Space(15);

            //Capture Selected Frames
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                DrawCaptureSelectedFramesGUI(TimelineEditor.selectedClip, timelineClipSISData);
                DrawLockFramesGUI(TimelineEditor.selectedClip, timelineClipSISData);
            }

            GUILayout.Space(15);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Background Colors");
                ++EditorGUI.indentLevel;

                RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig();

                Color updateBGColor   = editorConfig.GetUpdateBGColor();
                Color timelineBgColor = m_asset.GetTimelineBGColor();
                editorConfig.SetUpdateBGColor(EditorGUILayout.ColorField("In Game Window (Update)", updateBGColor));
                m_asset.SetTimelineBGColor(EditorGUILayout.ColorField("In Timeline Window", timelineBgColor));
                --EditorGUI.indentLevel;
                GUILayout.Space(5);
            }
            GUILayout.Space(15);
            DrawUpdateRenderCacheGUI();
        }
//----------------------------------------------------------------------------------------------------------------------

        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);
        }
//----------------------------------------------------------------------------------------------------------------------

        private static bool DrawSceneCacheImportSettings(SceneCachePlayer t)
        {
            bool changed = false;
            MeshSyncPlayerConfig playerConfig = t.GetConfigV();

            t.foldImportSettings = EditorGUILayout.Foldout(t.foldImportSettings, "Import Settings", true, GetBoldFoldoutStyle());
            if (t.foldImportSettings)
            {
                IHasModelImporterSettings importer         = AssetImporter.GetAtPath(t.GetSceneCacheFilePath()) as IHasModelImporterSettings;
                ModelImporterSettings     importerSettings = playerConfig.GetModelImporterSettings();

                if (null == importer)
                {
                    MeshSyncInspectorUtility.DrawModelImporterSettingsGUI(t, importerSettings);
                }
                else
                {
                    bool isOverride = t.IsModelImporterSettingsOverridden();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUIDrawerUtility.DrawUndoableGUI(t, "Override",
                                                           guiFunc: () => GUILayout.Toggle(isOverride, "", GUILayout.MaxWidth(15.0f)),
                                                           updateFunc: (bool overrideValue) => { t.OverrideModelImporterSettings(overrideValue); });

                    using (new EditorGUI.DisabledScope(!isOverride)) {
                        EditorGUIDrawerUtility.DrawUndoableGUI(t, "Create Materials",
                                                               guiFunc: () => (bool)EditorGUILayout.Toggle("Create Materials", importerSettings.CreateMaterials),
                                                               updateFunc: (bool createMat) => { importerSettings.CreateMaterials = createMat; });
                    }

                    EditorGUILayout.EndHorizontal();

                    using (new EditorGUI.DisabledScope(!isOverride)) {
                        ++EditorGUI.indentLevel;
                        MeshSyncInspectorUtility.DrawModelImporterMaterialSearchMode(t, importerSettings);
                        --EditorGUI.indentLevel;
                    }
                }



                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Animation Interpolation",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Animation Interpolation"),
                                                                                                       playerConfig.AnimationInterpolation, MeshSyncEditorConstants.ANIMATION_INTERPOLATION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.AnimationInterpolation = val; }
                                                                  );


                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Keyframe Reduction",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Keyframe Reduction", playerConfig.KeyframeReduction),
                                                                  updateFunc: (bool toggle) => { playerConfig.KeyframeReduction = toggle; }
                                                                  );

                if (playerConfig.KeyframeReduction)
                {
                    EditorGUI.indentLevel++;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Threshold",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Threshold", playerConfig.ReductionThreshold),
                                                                      updateFunc: (float val) => { playerConfig.ReductionThreshold = val; }
                                                                      );

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Erase Flat Curves",
                                                                      guiFunc: () => EditorGUILayout.Toggle("Erase Flat Curves", playerConfig.ReductionEraseFlatCurves),
                                                                      updateFunc: (bool toggle) => { playerConfig.ReductionEraseFlatCurves = toggle; }
                                                                      );
                    EditorGUI.indentLevel--;
                }

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Z-Up Correction",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Z-Up Correction"), playerConfig.ZUpCorrection,
                                                                                                       MeshSyncEditorConstants.Z_UP_CORRECTION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.ZUpCorrection = val; }
                                                                  );

                EditorGUILayout.Space();
            }

            return(changed);
        }
Exemplo n.º 19
0
//----------------------------------------------------------------------------------------------------------------------

    /// <summary>
    /// StreamingImageSequencePlayableAsset GUI Drawing
    /// </summary>
    public override void OnInspectorGUI() {
        if (null == m_asset)
            return;
        

        using (new EditorGUILayout.VerticalScope (GUI.skin.box))  {

            m_resolutionFoldout = EditorGUILayout.Foldout(m_resolutionFoldout, "Resolution");
            if (m_resolutionFoldout) {
                ImageDimensionInt res = m_asset.GetResolution();
                EditorGUILayout.LabelField("Width",  $"{res.Width } px");
                EditorGUILayout.LabelField("Height",  $"{res.Height } px");
            }
            GUILayout.Space(4f);
        }
        
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            GUILayout.Label("Folder", "BoldLabel");
            GUILayout.Space(4f);
            DrawFolderGUI();
        }
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            int numImages = m_asset.GetNumImages();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Images: " + numImages, "BoldLabel");            
            if (GUILayout.Button("Reload", GUILayout.Width(50))) {
                m_asset.Reload();
            }
            EditorGUILayout.EndHorizontal();
            
            using (new EditorGUI.DisabledScope(0 == numImages)) {
                if (0 == numImages)
                    EditorGUILayout.IntField("FPS", 0);
                else {
                    TimelineClip clip = m_asset.GetBoundClipData()?.GetOwner();
                    //There is no assigned clip if the playableAsset is not loaded in TimelineWindow
                    if (null != clip) {                         
                                                
                        EditorGUIDrawerUtility.DrawUndoableGUI(clip.GetParentTrack(), "Change FPS", 
                            /*guiFunc=*/ ()=> {
                                float fps = SISPlayableAssetUtility.CalculateFPS(m_asset);
                                float val = EditorGUILayout.FloatField("FPS", fps); 
                                return Mathf.Max(0.1f, val);
                            }, 
                            /*updateFunc=*/ (float newFPS) => {
                                SISPlayableAssetUtility.SetFPS(m_asset, newFPS);                                
                            }
                        );
                    }                    
                }
            }
            
            GUILayout.Space(4f);
            m_imageListFoldout = EditorGUILayout.Foldout(m_imageListFoldout, "Images");
            if (m_imageListFoldout) {
                DoImageGUI();
            }
        }

        if (null == TimelineEditor.selectedClip) 
            return;
        
        GUILayout.Space(15);
        //Frame markers
        if (TimelineEditor.selectedClip.asset == m_asset) {
            using (new EditorGUILayout.HorizontalScope()) {
                InspectorUtility.DrawFrameMarkersGUI(m_asset);
                if (GUILayout.Button("Reset", GUILayout.Width(50f))) {
                    m_asset.ResetPlayableFrames();
                }
            }
        }
        GUILayout.Space(15);
        
        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            EditorGUILayout.LabelField("Background Colors");
            ++EditorGUI.indentLevel;
            
            EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change BG Color", 
                /*guiFunc=*/ ()=> EditorGUILayout.ColorField("In Timeline Window", m_asset.GetTimelineBGColor()), 
                /*updateFunc=*/ (Color newColor) => {                               
                    m_asset.SetTimelineBGColor(newColor);                                
                }
            );
            
            --EditorGUI.indentLevel;
            GUILayout.Space(15);
        }

        
        if (GUILayout.Button("Reset Curve (Not Undoable)")) {
            //AnimationUtility.SetEditorCurve(), which is called below, doesn't seem to be undoable
            EditorCurveBinding curveBinding = StreamingImageSequencePlayableAsset.GetTimeCurveBinding();                 
            ExtendedClipEditorUtility.ResetClipDataCurve(m_asset, curveBinding);
        }
    }
//----------------------------------------------------------------------------------------------------------------------

        void DrawCacheSettings()
        {
            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle = FontStyle.Bold;

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

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

                if (newNormalizedPath != prevNormalizedPath)
                {
                    ChangeSceneCacheFileInInspector(m_sceneCachePlayer, 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(m_sceneCachePlayer, dstPath);
                    }
                    GUILayout.Label("Scene Cache file to StreamingAssets");
                    EditorGUILayout.LabelField("(RECOMMENDED)", EditorStyles.boldLabel);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                }
                EditorGUILayout.Space();


                EditorGUI.BeginChangeCheck();

                SceneCachePlayer.TimeUnit selectedTimeUnit = (SceneCachePlayer.TimeUnit)
                                                             EditorGUILayout.Popup("Time Unit", (int)m_sceneCachePlayer.GetTimeUnit(), m_timeUnitEnums);
                if (EditorGUI.EndChangeCheck())
                {
                    m_sceneCachePlayer.SetTimeUnit(selectedTimeUnit);
                    m_sceneCachePlayer.ResetTimeAnimation();
                }

                if (selectedTimeUnit == SceneCachePlayer.TimeUnit.Seconds)
                {
                    m_sceneCachePlayer.SetTime(EditorGUILayout.FloatField("Time", m_sceneCachePlayer.GetTime()));
                    m_sceneCachePlayer.SetInterpolation(EditorGUILayout.Toggle("Interpolation", m_sceneCachePlayer.GetInterpolation()));
                }
                else if (selectedTimeUnit == SceneCachePlayer.TimeUnit.Frames)
                {
                    EditorGUI.BeginChangeCheck();

                    SceneCachePlayer.BaseFrame selectedBaseFrame = (SceneCachePlayer.BaseFrame)
                                                                   EditorGUILayout.Popup("Base Frame", (int)m_sceneCachePlayer.GetBaseFrame(), m_baseFrameEnums);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_sceneCachePlayer.SetBaseFrame(selectedBaseFrame);
                        m_sceneCachePlayer.ResetTimeAnimation();
                    }

                    m_sceneCachePlayer.SetFrame(EditorGUILayout.IntField("Frame", m_sceneCachePlayer.GetFrame()));
                }

                // preload
                {
                    int preloadLength = EditorGUILayout.IntSlider("Preload Length", m_sceneCachePlayer.GetPreloadLength(), 0, m_sceneCachePlayer.frameCount);
                    m_sceneCachePlayer.SetPreloadLength(preloadLength);
                }

                EditorGUILayout.Space();
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        void DrawCacheSettings(SerializedObject so)
        {
            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle = FontStyle.Bold;

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

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

                if (newNormalizedPath != prevNormalizedPath)
                {
                    ChangeSceneCacheFileInInspector(m_sceneCachePlayer, 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(m_sceneCachePlayer, dstPath);
                    }
                    GUILayout.Label("Scene Cache file to StreamingAssets");
                    EditorGUILayout.LabelField("(RECOMMENDED)", EditorStyles.boldLabel);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                }
                EditorGUILayout.Space();

                // time / frame
                System.Action resetTimeAnimation = () => {
                    so.ApplyModifiedProperties();
                    m_sceneCachePlayer.ResetTimeAnimation();
                };

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(so.FindProperty("m_timeUnit"));
                if (EditorGUI.EndChangeCheck())
                {
                    resetTimeAnimation();
                }

                if (m_sceneCachePlayer.timeUnit == SceneCachePlayer.TimeUnit.Seconds)
                {
                    EditorGUILayout.PropertyField(so.FindProperty("m_time"));
                    EditorGUILayout.PropertyField(so.FindProperty("m_interpolation"));
                }
                else if (m_sceneCachePlayer.timeUnit == SceneCachePlayer.TimeUnit.Frames)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(so.FindProperty("m_baseFrame"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        resetTimeAnimation();
                    }

                    EditorGUILayout.PropertyField(so.FindProperty("m_frame"));
                }

                // preload
                {
                    SerializedProperty preloadLength = so.FindProperty("m_preloadLength");
                    preloadLength.intValue = EditorGUILayout.IntSlider("Preload Length", preloadLength.intValue, 0, m_sceneCachePlayer.frameCount);
                }

                EditorGUILayout.Space();
            }
        }
Exemplo n.º 22
0
//----------------------------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            //View resolution
            Vector2 res = ViewEditorUtility.GetMainGameViewSize();

            EditorGUILayout.LabelField("Resolution (Modify GameView size to change)");
            ++EditorGUI.indentLevel;
            EditorGUILayout.LabelField("Width", res.x.ToString(CultureInfo.InvariantCulture));
            EditorGUILayout.LabelField("Height", res.y.ToString(CultureInfo.InvariantCulture));
            --EditorGUI.indentLevel;
            EditorGUILayout.Space(15f);

            //Check if the asset is actually inspected
            if (null != TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset)
            {
                return;
            }

            ValidateAssetFolder();

            string prevFolder = m_asset.GetFolder();

            string newFolder = EditorGUIDrawerUtility.DrawFolderSelectorGUI("Cache Output Folder", "Select Folder",
                                                                            prevFolder, null
                                                                            );

            newFolder = AssetUtility.NormalizeAssetPath(newFolder);

            if (newFolder != prevFolder)
            {
                Undo.RecordObject(m_asset, "Change Output Folder");
                m_asset.SetFolder(AssetUtility.NormalizeAssetPath(newFolder));
                GUIUtility.ExitGUI();
            }

            //Output Format
            EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "RenderCache Output Format",
                                                   /*guiFunc=*/ () => (RenderCacheOutputFormat)EditorGUILayout.EnumPopup("Output Format:", m_asset.GetOutputFormat()),
                                                   /*updateFunc=*/ (RenderCacheOutputFormat newOutputFormat) => { m_asset.SetOutputFormat(newOutputFormat); }
                                                   );

            RenderCacheClipData clipData = m_asset.GetBoundClipData();

            if (null == clipData)
            {
                return;
            }

            GUILayout.Space(15);

            //Capture Selected Frames
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                DrawCaptureSelectedFramesGUI(TimelineEditor.selectedClip, clipData);
                DrawLockFramesGUI(TimelineEditor.selectedClip, clipData);
            }

            GUILayout.Space(15);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Background Colors");
                ++EditorGUI.indentLevel;

                RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig();

                EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change Update BG Color",
                                                       /*guiFunc=*/ () => EditorGUILayout.ColorField("In Game Window (Update)", editorConfig.GetUpdateBGColor()),
                                                       /*updateFunc=*/ (Color newColor) => { editorConfig.SetUpdateBGColor(newColor); }
                                                       );

                EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change Timeline BG Color",
                                                       /*guiFunc=*/ () => EditorGUILayout.ColorField("In Timeline Window", m_asset.GetTimelineBGColor()),
                                                       /*updateFunc=*/ (Color newColor) => { m_asset.SetTimelineBGColor(newColor); }
                                                       );

                --EditorGUI.indentLevel;
                GUILayout.Space(5);
            }
            GUILayout.Space(15);
            DrawUpdateRenderCacheGUI();
        }