void UpdatePreviewEnvironment() { var env = ProjectSettings.Get.GetMaterialPreviewEnvironment(); var multiplier = ProjectSettings.Get.MaterialPreviewEnvironmentMultiplier.Value; var affect = ProjectSettings.Get.MaterialPreviewEnvironmentAffectLighting.Value; if (!previewEnvironmentUsed.Equals(env) || previewEnvironmentMultiplierUsed != multiplier || previewEnvironmentAffectLightingUsed != affect) { previewEnvironmentUsed = env; previewEnvironmentMultiplierUsed = multiplier; previewEnvironmentAffectLightingUsed = affect; if (env.Value != null) { if (skybox == null) { skybox = Scene.CreateComponent <Component_Skybox>(); } skybox.Cubemap = env; skybox.Multiplier = multiplier; skybox.AffectLighting = affect; } else { skybox?.Dispose(); skybox = null; } } }
//protected override void Viewport_UpdateBeforeOutput( Viewport viewport ) //{ // base.Viewport_UpdateBeforeOutput( viewport ); // //update // if( instanceInScene != null && Time.Current > lastUpdateTime + 0.1 ) // { // CreateObject(); // lastUpdateTime = Time.Current; // } //} void CreateObject() { instanceInScene?.Dispose(); instanceInScene = (Component_Skybox)Skybox.Clone(); Scene.AddComponent(instanceInScene); }