//---------------------------------------------------------------------------------------------------------------------- public void Setup(VisualElement root) { VisualTreeAsset tab = UIElementsEditorUtility.LoadVisualTreeAsset(Constants.SERVER_SETTINGS_TAB_PATH); TemplateContainer tabInstance = tab.CloneTree(); VisualElement content = tabInstance.Query <VisualElement>("Content").First(); //Templates VisualTreeAsset fieldTemplate = LoadVisualTreeAsset(Constants.PROJECT_SETTINGS_FIELD_TEMPLATE_PATH); MeshSyncRuntimeSettings runtimeSettings = MeshSyncRuntimeSettings.GetOrCreateSettings(); //Add server port m_serverPortField = AddField <IntegerField, int>(fieldTemplate, content, Contents.ServerPort, runtimeSettings.GetDefaultServerPort(), (int newValue) => { MeshSyncRuntimeSettings settings = MeshSyncRuntimeSettings.GetOrCreateSettings(); settings.SetDefaultServerPort((ushort)newValue); } ); m_allowPublicAccessToggle = AddField <Toggle, bool>(fieldTemplate, content, Contents.AllowPublicAccess, runtimeSettings.GetServerPublicAccess(), (bool newValue) => { MeshSyncRuntimeSettings settings = MeshSyncRuntimeSettings.GetOrCreateSettings(); settings.SetServerPublicAccess(newValue); } ); //MeshSyncPlayerConfig section MeshSyncPlayerConfigSection section = new MeshSyncPlayerConfigSection(MeshSyncPlayerType.SERVER); section.Setup(content); root.Add(tabInstance); }
//---------------------------------------------------------------------------------------------------------------------- public void Setup(VisualElement root) { m_playerConfigUIElements = new List <VisualElement>(); VisualTreeAsset container = UIElementsEditorUtility.LoadVisualTreeAsset( Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "GeneralSettings_Container") ); TemplateContainer containerInstance = container.CloneTree(); List <string> objectTypes = new List <string> { MeshSyncPlayerType.SERVER.ToString(), MeshSyncPlayerType.CACHE_PLAYER.ToString(), }; //Templates VisualTreeAsset fieldTemplate = UIElementsEditorUtility.LoadVisualTreeAsset( Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "GeneralSettingsFieldTemplate") ); MeshSyncRuntimeSettings runtimeSettings = MeshSyncRuntimeSettings.GetOrCreateSettings(); VisualElement headerContainer = containerInstance.Query <VisualElement>("HeaderContainer").First(); //Add server port Foldout serverSettingsFoldout = containerInstance.Query <Foldout>("ServerSettingsFoldout").First(); m_serverPortField = AddField <IntegerField, int>(fieldTemplate, serverSettingsFoldout, Contents.ServerPort, runtimeSettings.GetDefaultServerPort(), (int newValue) => { MeshSyncRuntimeSettings settings = MeshSyncRuntimeSettings.GetOrCreateSettings(); settings.SetDefaultServerPort((ushort)newValue); } ); m_allowPublicAccessToggle = AddField <Toggle, bool>(fieldTemplate, serverSettingsFoldout, Contents.AllowPublicAccess, runtimeSettings.GetServerPublicAccess(), (bool newValue) => { MeshSyncRuntimeSettings settings = MeshSyncRuntimeSettings.GetOrCreateSettings(); settings.SetServerPublicAccess(newValue); } ); //Add playerType popup VisualElement playerTypePopupContainer = containerInstance.Query <VisualElement>("PlayerTypePopupContainer").First(); PopupField <string> playerTypePopup = new PopupField <string>("Settings for Object Type", objectTypes, objectTypes[0]); playerTypePopup.RegisterValueChangedCallback(OnPlayerTypePopupChanged); playerTypePopupContainer.Add(playerTypePopup); Foldout syncSettingsFoldout = containerInstance.Query <Foldout>("SyncSettingsFoldout").First(); //Sync m_syncVisibilityToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Visibility, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncVisibility = newValue; } ); m_syncTransformToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Transform, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncTransform = newValue; } ); m_syncCamerasToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Cameras, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncCameras = newValue; } ); m_syncLightsToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Lights, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncLights = newValue; } ); m_syncMeshesToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Meshes, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncMeshes = newValue; } ); m_updateMeshCollidersToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.UpdateMeshColliders, (MeshSyncPlayerConfig config, bool newValue) => { config.UpdateMeshColliders = newValue; } ); m_syncMaterialsToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.Materials, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncMaterials = newValue; } ); m_findMaterialFromAssetsToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, syncSettingsFoldout, Contents.FindMaterialsFromAssetDatabase, (MeshSyncPlayerConfig config, bool newValue) => { config.FindMaterialFromAssets = newValue; } ); //import Foldout importSettingsFoldout = containerInstance.Query <Foldout>("ImportSettingsFoldout").First(); m_animationInterpolationPopup = AddPlayerConfigPopupField(fieldTemplate, importSettingsFoldout, Contents.AnimationInterpolation, m_animationInterpolationEnums, (MeshSyncPlayerConfig config, int newValue) => { config.AnimationInterpolation = newValue; } ); m_keyframeReductionToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, importSettingsFoldout, Contents.KeyframeReduction, (MeshSyncPlayerConfig config, bool newValue) => { config.KeyframeReduction = newValue; } ); m_reductionThresholdField = AddPlayerConfigField <FloatField, float>(fieldTemplate, importSettingsFoldout, Contents.ReductionThreshold, (MeshSyncPlayerConfig config, float newValue) => { config.ReductionThreshold = newValue; } ); m_reductionEraseFlatCurves = AddPlayerConfigField <Toggle, bool>(fieldTemplate, importSettingsFoldout, Contents.ReductionEraseFlatCurves, (MeshSyncPlayerConfig config, bool newValue) => { config.ReductionEraseFlatCurves = newValue; } ); m_zUpCorrectionPopup = AddPlayerConfigPopupField(fieldTemplate, importSettingsFoldout, Contents.ZUpCorrection, m_zUpCorrectionEnums, (MeshSyncPlayerConfig config, int newValue) => { config.ZUpCorrection = newValue; } ); //Misc Foldout miscSettingsFoldout = containerInstance.Query <Foldout>("MiscSettingsFoldout").First(); m_syncMaterialListToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, miscSettingsFoldout, Contents.SyncMaterialList, (MeshSyncPlayerConfig config, bool newValue) => { config.SyncMaterialList = newValue; } ); m_progressiveDisplayToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, miscSettingsFoldout, Contents.ProgressiveDisplay, (MeshSyncPlayerConfig config, bool newValue) => { config.ProgressiveDisplay = newValue; } ); m_loggingToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, miscSettingsFoldout, Contents.Logging, (MeshSyncPlayerConfig config, bool newValue) => { config.Logging = newValue; } ); m_profilingToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, miscSettingsFoldout, Contents.Profiling, (MeshSyncPlayerConfig config, bool newValue) => { config.Profiling = newValue; } ); //Animation Tweak Foldout animationTweakSettingsFoldout = containerInstance.Query <Foldout>("AnimationTweakSettingsFoldout").First(); m_animationTweakTimeScaleField = AddPlayerConfigField <FloatField, float>(fieldTemplate, animationTweakSettingsFoldout, Contents.TweakTimeScale, (MeshSyncPlayerConfig config, float newValue) => { config.GetAnimationTweakSettings().TimeScale = newValue; } ); m_animationTweakTimeOffsetField = AddPlayerConfigField <FloatField, float>(fieldTemplate, animationTweakSettingsFoldout, Contents.TweakTimeOffset, (MeshSyncPlayerConfig config, float newValue) => { config.GetAnimationTweakSettings().TimeOffset = newValue; } ); m_animationTweakDropStepField = AddPlayerConfigField <IntegerField, int>(fieldTemplate, animationTweakSettingsFoldout, Contents.TweakDropStep, (MeshSyncPlayerConfig config, int newValue) => { config.GetAnimationTweakSettings().DropStep = newValue; } ); m_animationTweakReductionThresholdField = AddPlayerConfigField <FloatField, float>(fieldTemplate, animationTweakSettingsFoldout, Contents.TweakReductionThreshold, (MeshSyncPlayerConfig config, float newValue) => { config.GetAnimationTweakSettings().ReductionThreshold = newValue; } ); m_animationTweakEraseFlatCurvesToggle = AddPlayerConfigField <Toggle, bool>(fieldTemplate, animationTweakSettingsFoldout, Contents.TweakEraseFlatCurves, (MeshSyncPlayerConfig config, bool newValue) => { config.GetAnimationTweakSettings().EraseFlatCurves = newValue; } ); UpdatePlayerConfigUIElements(MeshSyncPlayerType.SERVER); root.Add(containerInstance); }