Merge pull request #206 from dwango/separate_shaderproperty

Separate shaderproperty
This commit is contained in:
ousttrue
2019-02-28 21:37:37 +09:00
committed by GitHub
53 changed files with 474 additions and 352 deletions

View File

@@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: 3fa98374d2ce76443981cc61ab80e6ce
guid: f877649750df3814aa5272250b22678c
folderAsset: yes
timeCreated: 1533035745
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36a5a07493511bd49b1ad9dbad2683d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
using System.Reflection;
using System.Linq;
using UnityEditor;
using UnityEngine;
using System.IO;
using UniGLTF.ShaderPropExporter;
using System.Collections.Generic;
namespace UniGLTF
{
public static class ShaderPropMenu
{
#if VRM_DEVELOP
[MenuItem("VRM/ShaderProperty/PreExport ShaderProps")]
#endif
public static void PreExport()
{
foreach (var fi in typeof(PreExportShaders).GetFields(
BindingFlags.Static
| BindingFlags.Public
| BindingFlags.NonPublic))
{
var attr = fi.GetCustomAttributes(true).FirstOrDefault(y => y is PreExportShadersAttribute);
if (attr != null)
{
var supportedShaders = fi.GetValue(null) as SupportedShader[];
foreach (var supported in supportedShaders)
{
PreExport(supported);
}
}
}
}
static string EscapeShaderName(string name)
{
return name.Replace("/", "_").Replace(" ", "_");
}
static string ExportDir
{
get
{
return Application.dataPath + "/VRM/ShaderProperty/Runtime";
}
}
static void PreExport(SupportedShader supportedShader)
{
var shader = Shader.Find(supportedShader.ShaderName);
var props = ShaderProps.FromShader(shader);
var path = Path.Combine(ExportDir, supportedShader.TargetFolder);
path = Path.Combine(path, EscapeShaderName(supportedShader.ShaderName) + ".cs").Replace("\\", "/");
Debug.LogFormat("PreExport: {0}", path);
File.WriteAllText(path, ToString(props, shader.name));
}
static string ToString(ShaderProps props, string shaderName)
{
var list = new List<string>();
foreach (var prop in props.Properties)
{
list.Add(string.Format("new ShaderProperty(\"{0}\", ShaderPropertyType.{1})\r\n", prop.Key, prop.ShaderPropertyType));
}
return string.Format(@"using System.Collections.Generic;
namespace UniGLTF.ShaderPropExporter
{{
public static partial class PreShaderPropExporter
{{
[PreExportShader]
static KeyValuePair<string, ShaderProps> {0}
{{
get
{{
return new KeyValuePair<string, ShaderProps>(
""{1}"",
new ShaderProps
{{
Properties = new ShaderProperty[]{{
{2}
}}
}}
);
}}
}}
}}
}}
"
, EscapeShaderName(shaderName)
, shaderName
, string.Join(",", list.ToArray()));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5eb12c186c6337e4db278b5f01d47cae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
{
"name": "ShaderProperty.Editor",
"references": [
"ShaderProperty.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bc66ece0f33b52446a0830c05781d4db
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd900b6f302c9404b99d77a1ae3d00be
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d9c97ad7f5bbcac489a47a2f34dfff00
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
namespace UniGLTF.ShaderPropExporter
{
public static partial class PreExportShaders
{
const string GLTF_FOLDER = "GLTF";
#pragma warning disable 414
[PreExportShaders]
static SupportedShader[] SupportedShaders = new SupportedShader[]
{
new SupportedShader(GLTF_FOLDER, "Standard"),
new SupportedShader(GLTF_FOLDER, "Unlit/Color"),
new SupportedShader(GLTF_FOLDER, "Unlit/Texture"),
new SupportedShader(GLTF_FOLDER, "Unlit/Transparent"),
new SupportedShader(GLTF_FOLDER, "Unlit/Transparent Cutout"),
new SupportedShader(GLTF_FOLDER, "UniGLTF/UniUnlit"),
};
#pragma warning restore 414
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90dcef1978c51e74386b76d77689dc82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UniGLTF.ShaderPropExporter
{
public class PreExportShadersAttribute : Attribute { }
public class PreExportShaderAttribute : Attribute { }
public struct SupportedShader
{
public string TargetFolder;
public string ShaderName;
public SupportedShader(string targetFolder, string shaderName)
{
TargetFolder = targetFolder;
ShaderName = shaderName;
}
}
public static partial class PreShaderPropExporter
{
static Dictionary<string, ShaderProps> m_shaderPropMap;
public static ShaderProps GetPropsForSupportedShader(string shaderName)
{
if (m_shaderPropMap == null)
{
m_shaderPropMap = new Dictionary<string, ShaderProps>();
foreach (var prop in typeof(PreShaderPropExporter).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
{
if (prop.GetCustomAttributes(typeof(PreExportShaderAttribute), true).Any())
{
var kv = (KeyValuePair<string, ShaderProps>)prop.GetValue(null, null);
m_shaderPropMap.Add(kv.Key, kv.Value);
}
}
}
ShaderProps props;
if (m_shaderPropMap.TryGetValue(shaderName, out props))
{
return props;
}
#if UNITY_EDITOR
// fallback
Debug.LogWarningFormat("{0} is not predefined shader. Use ShaderUtil", shaderName);
var shader = Shader.Find(shaderName);
return ShaderProps.FromShader(shader);
#else
return null;
#endif
}
}
}

View File

@@ -0,0 +1,8 @@
{
"name": "ShaderProperty.Runtime",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 301b251fd9834274c9228e0532f444f7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -62,50 +62,6 @@ namespace UniGLTF.ShaderPropExporter
Properties = properties.ToArray(),
};
}
static string EscapeShaderName(string name)
{
return name.Replace("/", "_").Replace(" ", "_");
}
public string ToString(string shaderName)
{
var list = new List<string>();
foreach (var prop in Properties)
{
list.Add(string.Format("new ShaderProperty(\"{0}\", ShaderPropertyType.{1})\r\n", prop.Key, prop.ShaderPropertyType));
}
return string.Format(@"using System.Collections.Generic;
namespace UniGLTF.ShaderPropExporter
{{
public static partial class PreShaderPropExporter
{{
[PreExportShader]
static KeyValuePair<string, ShaderProps> {0}
{{
get
{{
return new KeyValuePair<string, ShaderProps>(
""{1}"",
new ShaderProps
{{
Properties = new ShaderProperty[]{{
{2}
}}
}}
);
}}
}}
}}
}}
"
, EscapeShaderName(shaderName)
, shaderName
, String.Join(",", list.ToArray()));
}
#endif
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eb31f565eeca6164694b06ccfe3bc251
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +1,8 @@
namespace UniGLTF.ShaderPropExporter
{
public static partial class PreShaderPropExporter
public static partial class PreExportShaders
{
const string VRM_TARGET_FOLDER = "VRM/Scripts";
const string VRM_TARGET_FOLDER = "VRM";
[PreExportShaders]
public static SupportedShader[] VRMSupportedShaders = new SupportedShader[]
{

View File

@@ -1,7 +1,8 @@
{
"name": "UniGLTF.Editor",
"references": [
"VRM"
"VRM",
"ShaderProperty.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f877649750df3814aa5272250b22678c
guid: 892bd9a40a0e26a48b55fcb93590bf46
folderAsset: yes
timeCreated: 1533542717
licenseType: Free

View File

@@ -1,133 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UniGLTF.ShaderPropExporter
{
public class PreExportShadersAttribute : Attribute { }
public class PreExportShaderAttribute : Attribute { }
public struct SupportedShader
{
public string TargetFolder;
public string ShaderName;
public SupportedShader(string targetFolder, string shaderName)
{
TargetFolder = targetFolder;
ShaderName = shaderName;
}
}
public static partial class PreShaderPropExporter
{
const string TARGET_FOLDER = "UniGLTF/Core/Scripts";
#pragma warning disable 414
[PreExportShaders]
static SupportedShader[] SupportedShaders = new SupportedShader[]
{
new SupportedShader(TARGET_FOLDER, "Standard"),
new SupportedShader(TARGET_FOLDER, "Unlit/Color"),
new SupportedShader(TARGET_FOLDER, "Unlit/Texture"),
new SupportedShader(TARGET_FOLDER, "Unlit/Transparent"),
new SupportedShader(TARGET_FOLDER, "Unlit/Transparent Cutout"),
new SupportedShader(TARGET_FOLDER, "UniGLTF/UniUnlit"),
};
#pragma warning restore 414
#if UNITY_EDITOR
[MenuItem(UniGLTFVersion.MENU + "/PreExport ShaderProps")]
public static void PreExport()
{
foreach (var fi in typeof(PreShaderPropExporter).GetFields(
BindingFlags.Static
| BindingFlags.Public
| BindingFlags.NonPublic))
{
var attr = fi.GetCustomAttributes(true).FirstOrDefault(y => y is PreExportShadersAttribute);
if (attr != null)
{
var supportedShaders = fi.GetValue(null) as SupportedShader[];
foreach (var supported in supportedShaders)
{
PreExport(supported);
}
}
}
}
static string EscapeShaderName(string name)
{
return name.Replace("/", "_").Replace(" ", "_");
}
static UnityPath GetExportDir(string target)
{
foreach (var x in UnityPath.FromUnityPath("Assets").TravserseDir())
{
if (x.Value.EndsWith(target))
{
var dir = x.Child("PreExportShaderProps");
dir.EnsureFolder();
return dir;
}
}
throw new Exception(target + " not found");
}
static void PreExport(SupportedShader supportedShader)
{
var path = GetExportDir(supportedShader.TargetFolder).Child(EscapeShaderName(supportedShader.ShaderName) + ".cs");
Debug.LogFormat("PreExport: {0}", path.FullPath);
var shader = Shader.Find(supportedShader.ShaderName);
var props = ShaderProps.FromShader(shader);
File.WriteAllText(path.FullPath, props.ToString(shader.name));
}
#endif
#region Runtime
static Dictionary<string, ShaderProps> m_shaderPropMap;
public static ShaderProps GetPropsForSupportedShader(string shaderName)
{
if (m_shaderPropMap == null)
{
m_shaderPropMap = new Dictionary<string, ShaderProps>();
foreach (var prop in typeof(PreShaderPropExporter).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
{
if (prop.GetCustomAttributes(typeof(PreExportShaderAttribute), true).Any())
{
var kv = (KeyValuePair<string, ShaderProps>)prop.GetValue(null, null);
m_shaderPropMap.Add(kv.Key, kv.Value);
}
}
}
ShaderProps props;
if (m_shaderPropMap.TryGetValue(shaderName, out props))
{
return props;
}
#if UNITY_EDITOR
// fallback
Debug.LogWarningFormat("{0} is not predefined shader. Use ShaderUtil", shaderName);
var shader = Shader.Find(shaderName);
return ShaderProps.FromShader(shader);
#else
return null;
#endif
}
#endregion
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d9c97ad7f5bbcac489a47a2f34dfff00
guid: 98bc58647c431d04f8633bd7341c862b
folderAsset: yes
timeCreated: 1533538930
licenseType: Free

View File

@@ -204,7 +204,7 @@ namespace VRM
// materials
foreach (var m in exporter.Materials)
{
gltf.extensions.VRM.materialProperties.Add(glTF_VRM_Material.CreateFromMaterial(m, exporter.TextureManager.Textures));
gltf.extensions.VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, exporter.TextureManager.Textures));
}
}
}

View File

@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UniGLTF.ShaderPropExporter;
using UnityEngine;
@@ -96,5 +99,115 @@ namespace VRM
return material;
}
#region CreateFromMaterial
private static readonly string[] VRMExtensionShaders = new string[]
{
"VRM/UnlitTransparentZWrite",
"VRM/MToon"
};
static readonly string[] TAGS = new string[]{
"RenderType",
// "Queue",
};
public static glTF_VRM_Material CreateFromMaterial(Material m, List<Texture> textures)
{
var material = new glTF_VRM_Material
{
name = m.name,
shader = m.shader.name,
renderQueue = m.renderQueue,
};
if (!VRMExtensionShaders.Contains(m.shader.name))
{
material.shader = glTF_VRM_Material.VRM_USE_GLTFSHADER;
return material;
}
var prop = PreShaderPropExporter.GetPropsForSupportedShader(m.shader.name);
if (prop == null)
{
Debug.LogWarningFormat("Fail to export shader: {0}", m.shader.name);
}
else
{
foreach (var keyword in m.shaderKeywords)
{
material.keywordMap.Add(keyword, m.IsKeywordEnabled(keyword));
}
// get properties
//material.SetProp(prop);
foreach (var kv in prop.Properties)
{
switch (kv.ShaderPropertyType)
{
case ShaderPropertyType.Color:
{
var value = m.GetColor(kv.Key).ToArray();
material.vectorProperties.Add(kv.Key, value);
}
break;
case ShaderPropertyType.Range:
case ShaderPropertyType.Float:
{
var value = m.GetFloat(kv.Key);
material.floatProperties.Add(kv.Key, value);
}
break;
case ShaderPropertyType.TexEnv:
{
var texture = m.GetTexture(kv.Key);
if (texture != null)
{
var value = textures.IndexOf(texture);
if (value == -1)
{
Debug.LogFormat("not found {0}", texture.name);
}
else
{
material.textureProperties.Add(kv.Key, value);
}
}
// offset & scaling
var offset = m.GetTextureOffset(kv.Key);
var scaling = m.GetTextureScale(kv.Key);
material.vectorProperties.Add(kv.Key,
new float[] { offset.x, offset.y, scaling.x, scaling.y });
}
break;
case ShaderPropertyType.Vector:
{
var value = m.GetVector(kv.Key).ToArray();
material.vectorProperties.Add(kv.Key, value);
}
break;
default:
throw new NotImplementedException();
}
}
}
foreach (var tag in TAGS)
{
var value = m.GetTag(tag, false);
if (!String.IsNullOrEmpty(value))
{
material.tagMap.Add(tag, value);
}
}
return material;
}
#endregion
}
}

View File

@@ -0,0 +1,64 @@
using System.Linq;
using System.Collections.Generic;
using UniGLTF;
using UnityEngine;
namespace VRM
{
public static class glTF_VRMExtensions
{
public static glTF_VRM_BlendShapeBind Cerate(Transform root, List<Mesh> meshes, BlendShapeBinding binding)
{
var transform = UniGLTF.UnityExtensions.GetFromPath(root.transform, binding.RelativePath);
var renderer = transform.GetComponent<SkinnedMeshRenderer>();
var mesh = renderer.sharedMesh;
var meshIndex = meshes.IndexOf(mesh);
return new glTF_VRM_BlendShapeBind
{
mesh = meshIndex,
index = binding.Index,
weight = binding.Weight,
};
}
public static void Add(this glTF_VRM_BlendShapeMaster master,
BlendShapeClip clip, Transform transform, List<Mesh> meshes)
{
var list = new List<glTF_VRM_BlendShapeBind>();
if (clip.Values != null)
{
list.AddRange(clip.Values.Select(y => Cerate(transform, meshes.ToList(), y)));
}
var materialList = new List<glTF_VRM_MaterialValueBind>();
if (clip.MaterialValues != null)
{
materialList.AddRange(clip.MaterialValues.Select(y => new glTF_VRM_MaterialValueBind
{
materialName = y.MaterialName,
propertyName = y.ValueName,
targetValue = y.TargetValue.ToArray(),
}));
}
var group = new glTF_VRM_BlendShapeGroup
{
name = clip.BlendShapeName,
presetName = clip.Preset.ToString().ToLower(),
isBinary = clip.IsBinary,
binds = list,
materialValues = materialList,
};
master.blendShapeGroups.Add(group);
}
public static void Apply(this glTF_VRM_DegreeMap map, CurveMapper mapper)
{
map.curve = mapper.Curve.keys.SelectMany(x => new float[] { x.time, x.value, x.inTangent, x.outTangent }).ToArray();
map.xRange = mapper.CurveXRangeDegree;
map.yRange = mapper.CurveYRangeDegree;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5fbd5248b4a422e47be4510ca85c9ade
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,10 +1,9 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UniGLTF;
using UnityEngine;
using UniJSON;
namespace VRM
{
[Serializable]
@@ -42,21 +41,6 @@ namespace VRM
f.KeyValue(() => index);
f.KeyValue(() => weight);
}
public static glTF_VRM_BlendShapeBind Cerate(Transform root, List<Mesh> meshes, BlendShapeBinding binding)
{
var transform = UniGLTF.UnityExtensions.GetFromPath(root.transform, binding.RelativePath);
var renderer = transform.GetComponent<SkinnedMeshRenderer>();
var mesh = renderer.sharedMesh;
var meshIndex = meshes.IndexOf(mesh);
return new glTF_VRM_BlendShapeBind
{
mesh = meshIndex,
index = binding.Index,
weight = binding.Weight,
};
}
}
public enum BlendShapePreset
@@ -143,35 +127,6 @@ namespace VRM
{
public List<glTF_VRM_BlendShapeGroup> blendShapeGroups = new List<glTF_VRM_BlendShapeGroup>();
public void Add(BlendShapeClip clip, Transform transform, List<Mesh> meshes)
{
var list = new List<glTF_VRM_BlendShapeBind>();
if (clip.Values != null)
{
list.AddRange(clip.Values.Select(y => glTF_VRM_BlendShapeBind.Cerate(transform, meshes.ToList(), y)));
}
var materialList = new List<glTF_VRM_MaterialValueBind>();
if (clip.MaterialValues != null)
{
materialList.AddRange(clip.MaterialValues.Select(y => new glTF_VRM_MaterialValueBind
{
materialName = y.MaterialName,
propertyName = y.ValueName,
targetValue = y.TargetValue.ToArray(),
}));
}
var group = new glTF_VRM_BlendShapeGroup
{
name = clip.BlendShapeName,
presetName = clip.Preset.ToString().ToLower(),
isBinary = clip.IsBinary,
binds = list,
materialValues = materialList,
};
blendShapeGroups.Add(group);
}
protected override void SerializeMembers(GLTFJsonFormatter f)
{

View File

@@ -1,10 +1,10 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UniGLTF;
using UnityEngine;
using UniJSON;
namespace VRM
{
[Serializable]
@@ -29,13 +29,6 @@ namespace VRM
f.KeyValue(() => xRange);
f.KeyValue(() => yRange);
}
public void Apply(CurveMapper mapper)
{
curve = mapper.Curve.keys.SelectMany(x => new float[] { x.time, x.value, x.inTangent, x.outTangent }).ToArray();
xRange = mapper.CurveXRangeDegree;
yRange = mapper.CurveYRangeDegree;
}
}
public enum FirstPersonFlag

View File

@@ -2,9 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UnityEngine;
using UniJSON;
using UniGLTF.ShaderPropExporter;
namespace VRM
{
@@ -22,18 +21,7 @@ namespace VRM
public Dictionary<string, bool> keywordMap = new Dictionary<string, bool>();
public Dictionary<string, string> tagMap = new Dictionary<string, string>();
static readonly string[] TAGS = new string[]{
"RenderType",
// "Queue",
};
private static readonly string[] VRMExtensionShaders = new string[]
{
"VRM/UnlitTransparentZWrite",
"VRM/MToon"
};
private static readonly string VRM_USE_GLTFSHADER = "VRM_USE_GLTFSHADER";
public static readonly string VRM_USE_GLTFSHADER = "VRM_USE_GLTFSHADER";
protected override void SerializeMembers(GLTFJsonFormatter f)
{
@@ -116,102 +104,5 @@ namespace VRM
}
return materials;
}
public static glTF_VRM_Material CreateFromMaterial(Material m, List<Texture> textures)
{
var material = new glTF_VRM_Material
{
name = m.name,
shader = m.shader.name,
renderQueue = m.renderQueue,
};
if (!VRMExtensionShaders.Contains(m.shader.name))
{
material.shader = VRM_USE_GLTFSHADER;
return material;
}
var prop = PreShaderPropExporter.GetPropsForSupportedShader(m.shader.name);
if (prop == null)
{
Debug.LogWarningFormat("Fail to export shader: {0}", m.shader.name);
}
else
{
foreach (var keyword in m.shaderKeywords)
{
material.keywordMap.Add(keyword, m.IsKeywordEnabled(keyword));
}
// get properties
//material.SetProp(prop);
foreach (var kv in prop.Properties)
{
switch (kv.ShaderPropertyType)
{
case ShaderPropertyType.Color:
{
var value = m.GetColor(kv.Key).ToArray();
material.vectorProperties.Add(kv.Key, value);
}
break;
case ShaderPropertyType.Range:
case ShaderPropertyType.Float:
{
var value = m.GetFloat(kv.Key);
material.floatProperties.Add(kv.Key, value);
}
break;
case ShaderPropertyType.TexEnv:
{
var texture = m.GetTexture(kv.Key);
if (texture != null)
{
var value = textures.IndexOf(texture);
if (value == -1)
{
Debug.LogFormat("not found {0}", texture.name);
}
else
{
material.textureProperties.Add(kv.Key, value);
}
}
// offset & scaling
var offset = m.GetTextureOffset(kv.Key);
var scaling = m.GetTextureScale(kv.Key);
material.vectorProperties.Add(kv.Key,
new float[] { offset.x, offset.y, scaling.x, scaling.y });
}
break;
case ShaderPropertyType.Vector:
{
var value = m.GetVector(kv.Key).ToArray();
material.vectorProperties.Add(kv.Key, value);
}
break;
default:
throw new NotImplementedException();
}
}
}
foreach (var tag in TAGS)
{
var value = m.GetTag(tag, false);
if (!String.IsNullOrEmpty(value))
{
material.tagMap.Add(tag, value);
}
}
return material;
}
}
}

View File

@@ -5,7 +5,8 @@
"DepthFirstScheduler",
"UniUnlit",
"UniHumanoid",
"UniJSON"
"UniJSON",
"ShaderProperty.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [],