Ejemplo n.º 1
0
 private void SaveData(RegularShader s)
 {
     paths = s.paths.ToArray();
     CleanPaths(paths);
     ccOnly        = s.ccOnly;
     isTransparent = s.isTransparent;
     tints         = s.tints.ToArray();
     tiles         = s.uvTiles.ToArray();
 }
Ejemplo n.º 2
0
    /*
     *
     * Create Materials
     */

    Material SetupRegularMaterial(RegularShader shader, string basePath)
    {
        Material mat = new Material(Shader.Find(RegularShaderName));

        mat.SetFloat("_SmoothnessTextureChannel", 1f);
        mat.EnableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A");
        for (int i = 0; i < shader.paths.Count; i++)
        {
            if (shader.paths[i] != null && !shader.paths[i].Equals("null"))
            {
                Texture2D tex = (Texture2D)AssetDatabase.LoadAssetAtPath(basePath + shader.paths[i].Replace('\\', '/') + ".tif", typeof(Texture2D));
                if (tex == null)
                {
                    Debug.LogWarning("Failed to load texture:" + basePath + shader.paths[i]);
                    continue;
                }
                else
                {
                    //Debug.Log("Loaded:"+basePath+shader.paths[i]);
                }
                switch (i)
                {
                case 0:
                    mat.SetTexture("_MainTex", tex);
                    mat.SetTextureScale("_MainTex", shader.uvTiles[i]);
                    break;

                case 1:
                    mat.SetTexture("_DetailAlbedoMap", tex);
                    mat.SetTextureScale("_DetailAlbedoMap", shader.uvTiles[i]);
                    mat.EnableKeyword("_DETAIL_MULX2");
                    break;

                case 3:
                    mat.SetTexture("_BumpMap", tex);
                    mat.SetTextureScale("_BumpMap", shader.uvTiles[i]);
                    break;

                case 4:
                    mat.SetTexture("_DetailNormalMap", tex);
                    mat.SetTextureScale("_DetailNormalMap", shader.uvTiles[i]);
                    break;

                case 5:
                    Debug.Log("EMission map found for:" + shader.sName);
                    mat.EnableKeyword("_EMISSION");
                    mat.SetFloat("_EmissionScaleUI", 1);
                    mat.SetTexture("_EmissionMap", tex);
                    mat.SetTextureScale("_EmissionMap", shader.uvTiles[i]);
                    break;

                default:
                    Debug.LogWarning("Not sure where to put texture:[" + i + "]" + shader.paths[i]);
                    break;
                }
            }
        }

        //0
        mat.SetColor("_Color", shader.tints[0]);
        if (2 < shader.tints.Count)
        {
            mat.SetColor("_EmissionColor", shader.tints[2]);
        }


        if (shader.isTransparent)
        {
            mat.SetFloat("_Mode", 1f);
        }
        //mat.SetColor("_DetailAlbedoColor",shader.tints[1].ToColor32());
        mat.name = shader.sName;
        //mat.SetFloat("")

        return(mat);
    }