How to save material Texture without using the import UnityEditor
I am trying to save a cubemap texture to file an load it without using the import Unity Editor because it's not permetted in Built any one can help me .
using UnityEditor;
.............
foreach (var gameObj in FindObjectsOfType(typeof(GameObject)) as GameObject[])
{
if (gameObj.name.StartsWith("Chambre"))
{
PlayerPrefs.SetString("Chambre " + (l + 1), gameObj.name);
CurrentMaterial = new Material(Shader.Find("Skybox/Cubemap"));
CurrentMaterial = gameObj.GetComponent<MeshRenderer>().material;
var mainTexture = CurrentMaterial.GetTexture("_Tex");
if (!AssetDatabase.Contains(mainTexture))
{
AssetDatabase.CreateAsset(mainTexture, "Assets/Resources/Saved/chambre" + (l + 1) + ".mat");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
l++;
}
}
Comment