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

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

#if AT_USE_PROBUILDER
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Use Pro Builder",
                                                              guiFunc: () => EditorGUILayout.Toggle("Use Pro Builder", t.UseProBuilder),
                                                              updateFunc: (bool toggle) => { t.UseProBuilder = toggle; }
                                                              );
            EditorGUI.indentLevel--;
#endif

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

            EditorGUILayout.Space();

            return(changed);
        }
//----------------------------------------------------------------------------------------------------------------------
        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;
            }
        }
Example #3
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; }
                                      );
        }