mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-25 15:47:26 -05:00
VRM10 ScriptedImporter can detect project's RenderPipeline or select manually.
This commit is contained in:
parent
d5cffceca0
commit
6dba5bdf71
|
|
@ -6,7 +6,12 @@ namespace VRM
|
|||
{
|
||||
public static IMaterialDescriptorGenerator GetValidVrmMaterialDescriptorGenerator(glTF_VRM_extensions vrm)
|
||||
{
|
||||
return RenderPipelineUtility.GetRenderPipelineType() switch
|
||||
return GetVrmMaterialDescriptorGenerator(vrm, RenderPipelineUtility.GetRenderPipelineType());
|
||||
}
|
||||
|
||||
public static IMaterialDescriptorGenerator GetVrmMaterialDescriptorGenerator(glTF_VRM_extensions vrm, RenderPipelineTypes renderPipelineType)
|
||||
{
|
||||
return renderPipelineType switch
|
||||
{
|
||||
RenderPipelineTypes.UniversalRenderPipeline => new UrpVrmMaterialDescriptorGenerator(vrm),
|
||||
RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrmMaterialDescriptorGenerator(vrm),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using UnityEngine;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
|
|
@ -15,23 +16,11 @@ namespace UniVRM10
|
|||
public bool MigrateToVrm1 = default;
|
||||
|
||||
[SerializeField]
|
||||
public UniGLTF.RenderPipelineTypes RenderPipeline = default;
|
||||
public ImporterRenderPipelineTypes RenderPipeline = default;
|
||||
|
||||
public override void OnImportAsset(AssetImportContext ctx)
|
||||
{
|
||||
VrmScriptedImporterImpl.Import(this, ctx, MigrateToVrm1, RenderPipeline);
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
if (RenderPipeline == UniGLTF.RenderPipelineTypes.UniversalRenderPipeline)
|
||||
{
|
||||
if (Shader.Find(UniGLTF.UrpGltfPbrMaterialImporter.ShaderName) == null)
|
||||
{
|
||||
Debug.LogWarning("URP is not installed. Force to BuiltinRenderPipeline");
|
||||
RenderPipeline = UniGLTF.RenderPipelineTypes.BuiltinRenderPipeline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,23 +15,7 @@ namespace UniVRM10
|
|||
{
|
||||
public static class VrmScriptedImporterImpl
|
||||
{
|
||||
static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(RenderPipelineTypes renderPipeline)
|
||||
{
|
||||
var settings = Vrm10ProjectEditorSettings.instance;
|
||||
if (settings.MaterialDescriptorGeneratorFactory != null)
|
||||
{
|
||||
return settings.MaterialDescriptorGeneratorFactory.Create();
|
||||
}
|
||||
|
||||
return renderPipeline switch
|
||||
{
|
||||
RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialDescriptorGenerator(),
|
||||
RenderPipelineTypes.UniversalRenderPipeline => new UrpVrm10MaterialDescriptorGenerator(),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
|
||||
static void Process(Vrm10Data result, ScriptedImporter scriptedImporter, AssetImportContext context, RenderPipelineTypes renderPipeline)
|
||||
static void Process(Vrm10Data result, ScriptedImporter scriptedImporter, AssetImportContext context, ImporterRenderPipelineTypes renderPipeline)
|
||||
{
|
||||
//
|
||||
// Import(create unity objects)
|
||||
|
|
@ -73,7 +57,7 @@ namespace UniVRM10
|
|||
/// <param name="doMigrate">vrm0 だった場合に vrm1 化する</param>
|
||||
/// <param name="renderPipeline"></param>
|
||||
/// <param name="doNormalize">normalize する</param>
|
||||
public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool doMigrate, RenderPipelineTypes renderPipeline)
|
||||
public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool doMigrate, ImporterRenderPipelineTypes renderPipeline)
|
||||
{
|
||||
if (Symbols.VRM_DEVELOP)
|
||||
{
|
||||
|
|
@ -113,5 +97,22 @@ namespace UniVRM10
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(ImporterRenderPipelineTypes renderPipeline)
|
||||
{
|
||||
var settings = Vrm10ProjectEditorSettings.instance;
|
||||
if (settings.MaterialDescriptorGeneratorFactory != null)
|
||||
{
|
||||
return settings.MaterialDescriptorGeneratorFactory.Create();
|
||||
}
|
||||
|
||||
return renderPipeline switch
|
||||
{
|
||||
ImporterRenderPipelineTypes.Auto => Vrm10MaterialDescriptorGeneratorUtility.GetValidVrm10MaterialDescriptorGenerator(),
|
||||
ImporterRenderPipelineTypes.BuiltinRenderPipeline => Vrm10MaterialDescriptorGeneratorUtility.GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes.BuiltinRenderPipeline),
|
||||
ImporterRenderPipelineTypes.UniversalRenderPipeline => Vrm10MaterialDescriptorGeneratorUtility.GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes.UniversalRenderPipeline),
|
||||
_ => Vrm10MaterialDescriptorGeneratorUtility.GetValidVrm10MaterialDescriptorGenerator(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,12 @@ namespace UniVRM10
|
|||
{
|
||||
public static IMaterialDescriptorGenerator GetValidVrm10MaterialDescriptorGenerator()
|
||||
{
|
||||
return RenderPipelineUtility.GetRenderPipelineType() switch
|
||||
return GetVrm10MaterialDescriptorGenerator(RenderPipelineUtility.GetRenderPipelineType());
|
||||
}
|
||||
|
||||
public static IMaterialDescriptorGenerator GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes renderPipelineType)
|
||||
{
|
||||
return renderPipelineType switch
|
||||
{
|
||||
RenderPipelineTypes.UniversalRenderPipeline => new UrpVrm10MaterialDescriptorGenerator(),
|
||||
RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialDescriptorGenerator(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user