//---------------------------------------------------------------------------------------------------------------------- internal static SISUserSettings GetInstance() { if (null != m_instance) return m_instance; SISUserSettings settings = LoadUserSettings(); if (null != settings) { return settings; } m_instance = new SISUserSettings(); m_instance.SaveUserSettings(); return m_instance; }
//---------------------------------------------------------------------------------------------------------------------- void InitDefaultSISPlayableAssetFPSField(VisualElement parent) { //fps VisualElement fieldContainer = UIElementsUtility.AddElement <VisualElement>(parent, /*className=*/ "field-container"); SISUserSettings userSettings = SISUserSettings.GetInstance(); int defaultSISPlayableAssetFPS = userSettings.GetDefaultSISPlayableAssetFPS(); IntegerField defaultSISPlayableAssetFPSField = UIElementsUtility.AddField <IntegerField, int>(fieldContainer, Contents.DEFAULT_SIS_PLAYABLE_ASSET_FPS, defaultSISPlayableAssetFPS); defaultSISPlayableAssetFPSField.RegisterValueChangedCallback((ChangeEvent <int> evt) => { userSettings.SetDefaultSISPlayableAssetFPS(evt.newValue); userSettings.SaveUserSettings(); }); }
//---------------------------------------------------------------------------------------------------------------------- void InitMaxMemoryForImagesField(VisualElement parent) { //Prepare objects for binding SISUserSettings userSettings = SISUserSettings.GetInstance(); m_maxMemoryForImagesScriptableObject = ScriptableObject.CreateInstance <IntScriptableObject>(); m_maxMemoryForImagesScriptableObject.Value = userSettings.GetMaxImagesMemoryMB(); SerializedObject maxMemoryForImagesSerializedObject = new SerializedObject(m_maxMemoryForImagesScriptableObject); int maxImagesMemoryMB = userSettings.GetMaxImagesMemoryMB(); VisualElement fieldContainer = UIElementsUtility.AddElement <VisualElement>(parent, /*className=*/ "slider-field-container"); //Slider m_maxMemoryForImagesSliderInt = UIElementsUtility.AddField <SliderInt, int>(fieldContainer, Contents.MAX_MEMORY_FOR_IMAGES_MB, maxImagesMemoryMB); m_maxMemoryForImagesSliderInt.lowValue = 4096; m_maxMemoryForImagesSliderInt.highValue = 131072; m_maxMemoryForImagesSliderInt.bindingPath = nameof(IntScriptableObject.Value); m_maxMemoryForImagesSliderInt.Bind(maxMemoryForImagesSerializedObject); //IntField m_maxMemoryForImagesIntField = UIElementsUtility.AddField <IntegerField, int>(fieldContainer, null, maxImagesMemoryMB); m_maxMemoryForImagesIntField.bindingPath = nameof(IntScriptableObject.Value); m_maxMemoryForImagesIntField.Bind(maxMemoryForImagesSerializedObject); Label sliderIntValuePostLabel = UIElementsUtility.AddElement <Label>(fieldContainer); sliderIntValuePostLabel.text = "MB "; m_maxMemoryForImagesIntField.RegisterValueChangedCallback((ChangeEvent <int> evt) => { userSettings.SetMaxImagesMemoryMB(evt.newValue); userSettings.SaveUserSettings(); }); }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } StreamingImageSequenceTrack sisTrack = track as StreamingImageSequenceTrack; Assert.IsNotNull(sisTrack); //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.parentTrack = track; //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { int numImages = asset.GetNumImages(); if (numImages > 0) { SISUserSettings userSettings = SISUserSettings.GetInstance(); clip.duration = (double)(numImages) / (userSettings.GetDefaultSISPlayableAssetFPS()); clip.displayName = Path.GetFileName(asset.GetFolder()); } clip.CreateCurves("Curves: " + clip.displayName); } TimelineClipSISData sisData = null; asset.InitTimelineClipCurve(clip); if (null == clonedFrom) { sisData = new TimelineClipSISData(clip); asset.BindTimelineClipSISData(sisData); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); TimelineClipSISData otherSISData = clonedFromAsset.GetBoundTimelineClipSISData(); sisData = new TimelineClipSISData(clip, otherSISData); asset.BindTimelineClipSISData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }
static void SISUserSettings_OnLoadRuntime() { SISUserSettings userSettings = GetInstance(); StreamingImageSequencePlugin.SetMaxImagesMemory(userSettings.GetMaxImagesMemoryMB()); }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } //[Note-sin: 2021-2-25] Track can be null during copy and paste if (null != track) { //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.TryMoveToTrack(track); } //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { int numImages = asset.GetNumImages(); if (numImages > 0) { SISUserSettings userSettings = SISUserSettings.GetInstance(); clip.duration = (double)(numImages) / (userSettings.GetDefaultSISPlayableAssetFPS()); clip.displayName = Path.GetFileName(asset.GetFolder()); } ExtendedClipEditorUtility.CreateTimelineClipCurve(clip, StreamingImageSequencePlayableAsset.GetTimeCurveBinding()); } if (null == clonedFrom) { asset.BindClipData(new SISClipData(clip)); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); SISClipData otherSISData = clonedFromAsset.GetBoundClipData(); if (null == otherSISData) { asset.BindClipData(new SISClipData(clip)); //[Note-sin: 2021-2-25] can be null during copy and paste return; } SISClipData sisData = new SISClipData(clip, otherSISData); asset.BindClipData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }