예제 #1
0
//----------------------------------------------------------------------------------------------------------------------    
    /// <inheritdoc/>
    public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) {
        
        SceneCachePlayableAsset asset = clip.asset as SceneCachePlayableAsset;
        if (null == asset) {
            Debug.LogError("[MeshSync] Asset is not a SceneCachePlayableAsset: " + clip.asset);
            return;
        }
        
        SceneCachePlayerConfig config = MeshSyncProjectSettings.GetOrCreateSettings().GetDefaultSceneCachePlayerConfig();        
        asset.SetSnapToFrame((SnapToFrame) config.TimelineSnapToFrame);

        //OnCreate() is called before the clip is assigned to the track, but we need the track for creating curves.
        clip.TryMoveToTrack(track);
                       
    }
예제 #2
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; }
                                      );
        }