public override void Create() { output.CalculateTextures(); MaterialPreviewEditor.forceRepaint(); Repaint(); status = STATUS_NONE; }
public void CalculateTextures() { CTextureNode Heightmap = (CTextureNode)getNode(Inputs, 0); CTextureNode ColorMap = (CTextureNode)getNode(Inputs, 1); CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2); if (NormalMap == null || ColorMap == null || Heightmap == null) { return; } Heightmap.GenerateTexture(); ColorMap.GenerateTexture(); NormalMap.GenerateTexture(); MaterialPreviewEditor.SetTextures(NormalMap.texture, Heightmap.texture, ColorMap.texture, MaterialPreviewEditor.currentMaterial); MaterialPreviewEditor.forceRepaint(); CNodeManager.Progress(); }
public void Export(string file) { // CTextureNode ShininessMap = (CTextureNode)getNode (Inputs, 0); CTextureNode HeightMap = (CTextureNode)getNode(Inputs, 0); CTextureNode ColorMap = (CTextureNode)getNode(Inputs, 1); CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2); string FileNormalMap = file + "_Normal"; string FileColorMap = file + "_Color"; string FileHeightMap = file + "_Height"; MaterialPreviewEditor.forceRepaint(); if (NormalMap != null) { Util.SaveTextureFile(NormalMap.texture, "", FileNormalMap); } if (ColorMap != null) { Util.SaveTextureFile(ColorMap.texture, "", FileColorMap); } if (HeightMap != null) { Util.SaveTextureFile(HeightMap.texture, "", FileHeightMap); } AssetDatabase.Refresh(); try { Material mat = new Material(file); //MaterialPreviewEditor.currentMaterial; AssetDatabase.CreateAsset(mat, file + ".mat"); mat.shader = MaterialPreviewEditor.currentMaterial.shader; Texture2D T_hm = (Texture2D)AssetDatabase.LoadAssetAtPath(FileHeightMap + ".png", typeof(Texture2D)); Texture2D T_c = (Texture2D)AssetDatabase.LoadAssetAtPath(FileColorMap + ".png", typeof(Texture2D)); // Texture2D T_ex = (Texture2D)AssetDatabase.LoadAssetAtPath(FileExtraMap + ".png", typeof(Texture2D)); Texture2D T_nr = (Texture2D)AssetDatabase.LoadAssetAtPath(FileNormalMap + ".png", typeof(Texture2D)); MaterialPreviewEditor.SetTextures(T_nr, T_hm, T_c, mat); MaterialPreviewEditor.SetProperties(mat); } catch (System.Exception e) { Debug.Log(e.Message); } }