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);
    }
 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; });
     }
 }
//----------------------------------------------------------------------------------------------------------------------
        internal void Setup(VisualElement parent)
        {
            bool isSceneCachePlayerConfig           = (m_playerType == MeshSyncPlayerType.CACHE_PLAYER);
            MeshSyncProjectSettings projectSettings = MeshSyncProjectSettings.GetOrCreateInstance();
            MeshSyncPlayerConfig    config          = null;

            config = isSceneCachePlayerConfig
            ? (MeshSyncPlayerConfig)projectSettings.GetDefaultSceneCachePlayerConfig()
            : projectSettings.GetDefaultServerConfig();


            TemplateContainer containerInstance = InstantiateContainer(m_playerType);

            parent.Add(containerInstance);

            //Add server port
            Foldout syncSettingsFoldout = containerInstance.Query <Foldout>("SyncSettingsFoldout").First();

            //Sync
            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UpdateTransform, config.SyncTransform,
                                                (bool newValue) => { config.SyncTransform = newValue; }
                                                );

            {
                int i = MeshSyncPlayerConfig.SYNC_CAMERA;
                ComponentSyncSettings componentSyncSettings = config.GetComponentSyncSettings(i);
                AddComponentSyncSettingFields(syncSettingsFoldout, Contents.ComponentSyncs[i], componentSyncSettings);
            }

            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UsePhysicalCameraParams, config.IsPhysicalCameraParamsUsed(),
                                                (bool newValue) => { config.UsePhysicalCameraParams(newValue); },
                                                "inner-field-container"
                                                );

            {
                int i = MeshSyncPlayerConfig.SYNC_LIGHTS;
                ComponentSyncSettings componentSyncSettings = config.GetComponentSyncSettings(i);
                AddComponentSyncSettingFields(syncSettingsFoldout, Contents.ComponentSyncs[i], componentSyncSettings);
            }


            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.Meshes, config.SyncMeshes,
                                                (bool newValue) => { config.SyncMeshes = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UpdateMeshColliders, config.UpdateMeshColliders,
                                                (bool newValue) => { config.UpdateMeshColliders = newValue; },
                                                "inner-field-container"
                                                );

            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.Visibility, config.SyncVisibility,
                                                (bool newValue) => { config.SyncVisibility = newValue; }
                                                );

            //import
            Foldout importSettingsFoldout = containerInstance.Query <Foldout>("ImportSettingsFoldout").First();
            ModelImporterSettings modelImporterSettings = config.GetModelImporterSettings();

            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout,
                                                Contents.CreateMaterials, modelImporterSettings.CreateMaterials,
                                                (bool newValue) => { modelImporterSettings.CreateMaterials = newValue; }
                                                );
            AddPlayerConfigPopupField(importSettingsFoldout, Contents.MaterialSearchMode, m_assetSearchModeEnums,
                                      m_assetSearchModeEnums[(int)modelImporterSettings.MaterialSearchMode],
                                      (int newValue) => { modelImporterSettings.MaterialSearchMode = (AssetSearchMode)newValue; },
                                      "inner-field-container"
                                      );

            AddPlayerConfigPopupField(importSettingsFoldout, Contents.AnimationInterpolation, m_animationInterpolationEnums,
                                      m_animationInterpolationEnums[config.AnimationInterpolation],
                                      (int newValue) => { config.AnimationInterpolation = newValue; }
                                      );
            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout, Contents.KeyframeReduction, config.KeyframeReduction,
                                                (bool newValue) => { config.KeyframeReduction = newValue; }
                                                );
            AddPlayerConfigField <FloatField, float>(importSettingsFoldout,
                                                     Contents.ReductionThreshold, config.ReductionThreshold,
                                                     (float newValue) => { config.ReductionThreshold = newValue; }
                                                     );
            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout,
                                                Contents.ReductionEraseFlatCurves, config.ReductionEraseFlatCurves,
                                                (bool newValue) => { config.ReductionEraseFlatCurves = newValue; }
                                                );
            AddPlayerConfigPopupField(importSettingsFoldout,
                                      Contents.ZUpCorrection, m_zUpCorrectionEnums, m_zUpCorrectionEnums[config.ZUpCorrection],
                                      (int newValue) => { config.ZUpCorrection = newValue; }
                                      );

            //Misc
            Foldout miscSettingsFoldout = containerInstance.Query <Foldout>("MiscSettingsFoldout").First();

            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout,
                                                Contents.SyncMaterialList, config.SyncMaterialList,
                                                (bool newValue) => { config.SyncMaterialList = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.ProgressiveDisplay, config.ProgressiveDisplay,
                                                (bool newValue) => { config.ProgressiveDisplay = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.Logging, config.Logging,
                                                (bool newValue) => { config.Logging = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.Profiling, config.Profiling,
                                                (bool newValue) => { config.Profiling = newValue; }
                                                );


            if (!isSceneCachePlayerConfig)
            {
                return;
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        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);
        }
예제 #5
0
//----------------------------------------------------------------------------------------------------------------------
        internal void Setup(VisualElement parent)
        {
            bool isSceneCachePlayerConfig = (m_playerType == MeshSyncPlayerType.CACHE_PLAYER);
            MeshSyncPlayerConfig config   = null;

            if (isSceneCachePlayerConfig)
            {
                config = MeshSyncProjectSettings.GetOrCreateSettings().GetDefaultSceneCachePlayerConfig();
            }
            else
            {
                config = MeshSyncProjectSettings.GetOrCreateSettings().GetDefaultServerConfig();
            }


            TemplateContainer containerInstance = InstantiateContainer(m_playerType);

            parent.Add(containerInstance);

            //Add server port
            Foldout syncSettingsFoldout = containerInstance.Query <Foldout>("SyncSettingsFoldout").First();

            //Sync
            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UpdateTransform, config.SyncTransform,
                                                (bool newValue) => { config.SyncTransform = newValue; }
                                                );

            {
                int i = MeshSyncPlayerConfig.SYNC_CAMERA;
                ComponentSyncSettings componentSyncSettings = config.GetComponentSyncSettings(i);
                AddComponentSyncSettingFields(syncSettingsFoldout, Contents.ComponentSyncs[i], componentSyncSettings);
            }

            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UsePhysicalCameraParams, config.IsPhysicalCameraParamsUsed(),
                                                (bool newValue) => { config.UsePhysicalCameraParams(newValue); },
                                                "inner-field-container"
                                                );

            {
                int i = MeshSyncPlayerConfig.SYNC_LIGHTS;
                ComponentSyncSettings componentSyncSettings = config.GetComponentSyncSettings(i);
                AddComponentSyncSettingFields(syncSettingsFoldout, Contents.ComponentSyncs[i], componentSyncSettings);
            }


            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.Meshes, config.SyncMeshes,
                                                (bool newValue) => { config.SyncMeshes = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.UpdateMeshColliders, config.UpdateMeshColliders,
                                                (bool newValue) => { config.UpdateMeshColliders = newValue; },
                                                "inner-field-container"
                                                );

            AddPlayerConfigField <Toggle, bool>(syncSettingsFoldout, Contents.Visibility, config.SyncVisibility,
                                                (bool newValue) => { config.SyncVisibility = newValue; }
                                                );

            //import
            Foldout importSettingsFoldout = containerInstance.Query <Foldout>("ImportSettingsFoldout").First();
            ModelImporterSettings modelImporterSettings = config.GetModelImporterSettings();

            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout,
                                                Contents.CreateMaterials, modelImporterSettings.CreateMaterials,
                                                (bool newValue) => { modelImporterSettings.CreateMaterials = newValue; }
                                                );
            AddPlayerConfigPopupField(importSettingsFoldout, Contents.MaterialSearchMode, m_assetSearchModeEnums,
                                      m_assetSearchModeEnums[(int)modelImporterSettings.MaterialSearchMode],
                                      (int newValue) => { modelImporterSettings.MaterialSearchMode = (AssetSearchMode)newValue; },
                                      "inner-field-container"
                                      );

            AddPlayerConfigPopupField(importSettingsFoldout, Contents.AnimationInterpolation, m_animationInterpolationEnums,
                                      m_animationInterpolationEnums[config.AnimationInterpolation],
                                      (int newValue) => { config.AnimationInterpolation = newValue; }
                                      );
            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout, Contents.KeyframeReduction, config.KeyframeReduction,
                                                (bool newValue) => { config.KeyframeReduction = newValue; }
                                                );
            AddPlayerConfigField <FloatField, float>(importSettingsFoldout,
                                                     Contents.ReductionThreshold, config.ReductionThreshold,
                                                     (float newValue) => { config.ReductionThreshold = newValue; }
                                                     );
            AddPlayerConfigField <Toggle, bool>(importSettingsFoldout,
                                                Contents.ReductionEraseFlatCurves, config.ReductionEraseFlatCurves,
                                                (bool newValue) => { config.ReductionEraseFlatCurves = newValue; }
                                                );
            AddPlayerConfigPopupField(importSettingsFoldout,
                                      Contents.ZUpCorrection, m_zUpCorrectionEnums, m_zUpCorrectionEnums[config.ZUpCorrection],
                                      (int newValue) => { config.ZUpCorrection = newValue; }
                                      );

            //Misc
            Foldout miscSettingsFoldout = containerInstance.Query <Foldout>("MiscSettingsFoldout").First();

            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout,
                                                Contents.SyncMaterialList, config.SyncMaterialList,
                                                (bool newValue) => { config.SyncMaterialList = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.ProgressiveDisplay, config.ProgressiveDisplay,
                                                (bool newValue) => { config.ProgressiveDisplay = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.Logging, config.Logging,
                                                (bool newValue) => { config.Logging = newValue; }
                                                );
            AddPlayerConfigField <Toggle, bool>(miscSettingsFoldout, Contents.Profiling, config.Profiling,
                                                (bool newValue) => { config.Profiling = newValue; }
                                                );

            //Animation Tweak
            Foldout atsFoldout         = containerInstance.Query <Foldout>("AnimationTweakSettingsFoldout").First();
            AnimationTweakSettings ats = config.GetAnimationTweakSettings();

            AddPlayerConfigField <FloatField, float>(atsFoldout, Contents.TweakTimeScale, ats.TimeScale,
                                                     (float newValue) => { ats.TimeScale = newValue; }
                                                     );
            AddPlayerConfigField <FloatField, float>(atsFoldout, Contents.TweakTimeOffset, ats.TimeOffset,
                                                     (float newValue) => { ats.TimeOffset = newValue; }
                                                     );
            AddPlayerConfigField <IntegerField, int>(atsFoldout, Contents.TweakDropStep, ats.DropStep,
                                                     (int newValue) => { ats.DropStep = newValue; }
                                                     );
            AddPlayerConfigField <FloatField, float>(atsFoldout, Contents.TweakReductionThreshold, ats.ReductionThreshold,
                                                     (float newValue) => { ats.ReductionThreshold = newValue; }
                                                     );
            AddPlayerConfigField <Toggle, bool>(atsFoldout, Contents.TweakEraseFlatCurves, ats.EraseFlatCurves,
                                                (bool newValue) => { ats.EraseFlatCurves = newValue; }
                                                );

            if (!isSceneCachePlayerConfig)
            {
                return;
            }

            //Additional UI for SceneCache
            SceneCachePlayerConfig scPlayerConfig = config as SceneCachePlayerConfig;

            Assert.IsNotNull(scPlayerConfig);
            Foldout timelineSettingsFoldout = containerInstance.Query <Foldout>("TimelineSettingsFoldout").First();

            AddPlayerConfigPopupField(timelineSettingsFoldout,
                                      Contents.TimelineSnapToFrame, m_snapToFrameEnums, m_snapToFrameEnums[scPlayerConfig.TimelineSnapToFrame],
                                      (int newValue) => { scPlayerConfig.TimelineSnapToFrame = newValue; }
                                      );
        }