Beispiel #1
0
    public static void loadMaterial(this MyMaterial m)
    {
        MaterialSetting ms = m.getSetting();

        if (ms.material == null)
        {
            if (File.Exists(Application.dataPath + "/Resources/Material/" + m + ".mat") == false)
            {
                File.Copy(Application.dataPath + "/Resources/Material/DEFAULT.mat", Application.dataPath + "/Resources/Material/" + m + ".mat");
            }
            ms.material = Resources.Load <Material>("Material\\" + m);
        }
        bool found = false;

        foreach (TextureType type in Enum.GetValues(typeof(TextureType)))
        {
            if (ms.getTexture(type) != null)
            {
                Material mat = new Material(ms.material);
                mat.mainTexture = ms.getTexture(type);
                ChunkMeshCreator.materials.Add(m + "_" + type, mat);
                found = true;
            }
        }
        if (found == false)
        {
            Material mat = new Material(GameManager.getGameManager().itemMaterial);
            ChunkMeshCreator.materials.Add(m + "_" + TextureType.NORMAL, mat);
            //GameManager.getGameManager().webHandler.giveRandomTexture(mat, name.Replace("_", " "));
        }
    }