//public Texture2D m_Cached; public override Node Create(Vector2 pos) { UnityTextureOutputMetalicAndRoughness node = CreateInstance <UnityTextureOutputMetalicAndRoughness> (); node.rect = new Rect(pos.x, pos.y, 150, 150); node.name = "OutputMetalicAndRoughness"; node.CreateInput("Metalic", "TextureParam", NodeSide.Left, 50); node.CreateInput("Roughness", "TextureParam", NodeSide.Left, 80); return(node); }
private Texture2D MakeTextureNodeAndTexture(string texName, Vector2 _pos, bool _isNorm, string _nodeTypeName, out Node _node) { string albedo = MakePNG(m_Path, texName); AssetDatabase.Refresh(); TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath(albedo); if (_isNorm) { importer.textureType = TextureImporterType.NormalMap; } else { importer.textureType = TextureImporterType.Default; } importer.textureCompression = TextureImporterCompression.Uncompressed; importer.isReadable = true; AssetDatabase.ImportAsset(albedo, ImportAssetOptions.ForceSynchronousImport); Texture2D albedoTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(albedo, typeof(Texture2D)); var n = Node.Create(_nodeTypeName, _pos); _node = n; UnityTextureOutput uto = n as UnityTextureOutput; if (uto != null) { uto.m_Output = albedoTexture; uto.m_TexName = albedo; } UnityTextureOutputMetalicAndRoughness utometal = n as UnityTextureOutputMetalicAndRoughness; if (utometal != null) { utometal.m_Output = albedoTexture; utometal.m_TexName = albedo; } return(albedoTexture); }