コード例 #1
0
            static void RenderInCustomAsset(HDProbe probe, bool useExistingCustomAsset)
            {
                var provider = new TProvider();

                string assetPath = null;

                if (useExistingCustomAsset && probe.customTexture != null && !probe.customTexture.Equals(null))
                {
                    assetPath = AssetDatabase.GetAssetPath(probe.customTexture);
                }

                if (string.IsNullOrEmpty(assetPath))
                {
                    assetPath = EditorUtility.SaveFilePanelInProject(
                        "Save custom capture",
                        probe.name, "exr",
                        "Save custom capture");
                }

                if (!string.IsNullOrEmpty(assetPath))
                {
                    var target = HDProbeSystem.CreateRenderTargetForMode(
                        probe, ProbeSettings.Mode.Custom
                        );
                    HDProbeSystem.Render(
                        probe, null, target,
                        out HDProbe.RenderData renderData,
                        forceFlipY: probe.type == ProbeSettings.ProbeType.ReflectionProbe
                        );
                    HDTextureUtilities.WriteTextureFileToDisk(target, assetPath);
                    AssetDatabase.ImportAsset(assetPath);
                    HDBakedReflectionSystem.ImportAssetAt(probe, assetPath);
                    CoreUtils.Destroy(target);

                    var assetTarget = AssetDatabase.LoadAssetAtPath <Texture>(assetPath);
                    probe.SetTexture(ProbeSettings.Mode.Custom, assetTarget);
                    probe.SetRenderData(ProbeSettings.Mode.Custom, renderData);
                    EditorUtility.SetDirty(probe);
                }
            }
コード例 #2
0
            static void RenderInCustomAsset(HDProbe probe, bool useExistingCustomAsset)
            {
                var provider = new TProvider();

                string assetPath = null;

                if (useExistingCustomAsset && probe.customTexture != null && !probe.customTexture.Equals(null))
                {
                    assetPath = AssetDatabase.GetAssetPath(probe.customTexture);
                }

                if (string.IsNullOrEmpty(assetPath))
                {
                    assetPath = EditorUtility.SaveFilePanelInProject(
                        "Save custom capture",
                        probe.name, "exr",
                        "Save custom capture");
                }

                if (!string.IsNullOrEmpty(assetPath))
                {
                    var target = (RenderTexture)HDProbeSystem.CreateRenderTargetForMode(
                        probe, ProbeSettings.Mode.Custom
                        );


                    HDBakedReflectionSystem.RenderAndWriteToFile(
                        probe, assetPath, target, null,
                        out var cameraSettings, out var cameraPositionSettings
                        );
                    AssetDatabase.ImportAsset(assetPath);
                    HDBakedReflectionSystem.ImportAssetAt(probe, assetPath);
                    CoreUtils.Destroy(target);

                    var assetTarget = AssetDatabase.LoadAssetAtPath <Texture>(assetPath);
                    probe.SetTexture(ProbeSettings.Mode.Custom, assetTarget);
                    probe.SetRenderData(ProbeSettings.Mode.Custom, new HDProbe.RenderData(cameraSettings, cameraPositionSettings));
                    EditorUtility.SetDirty(probe);
                }
            }