using Godot; using System.Reflection; using System.Collections.Generic; namespace Rokojori { public partial class CustomMaterial:ShaderMaterial { public void CopyUniformsFrom( ShaderMaterial material ) { var uniforms = Shaders.GetUniformNames( material.Shader ); uniforms.ForEach( u => { SetShaderParameter( u, material.GetShaderParameter( u ) ); } ); } public static T CreateFrom( ShaderMaterial m ) where T:CustomMaterial, new() { var t = new T(); t.CopyUniformsFrom( m ); return t; } public static CachedResource Cached( string path ) where T:CustomMaterial, new() { var cachedResource = new CachedResource( path, ( r ) => { return CreateFrom( r as ShaderMaterial ); } ); return cachedResource; } } }