Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Created January 15, 2019 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyx69/14655bc04d94fc6557dfc79739cef832 to your computer and use it in GitHub Desktop.
Save ronyx69/14655bc04d94fc6557dfc79739cef832 to your computer and use it in GitHub Desktop.
Converts a texture to a different format for dumping with mod tools, for cases where some textures can't be dumped normally. Puts the converted texture in Sunny Properties > Sunny Net > NetProperties >m_downwardDiffuse
// map theme texture
var source = UnityEngine.Object.FindObjectOfType<TerrainProperties>().m_grassDiffuse;
var target = new Texture2D(source.width, source.height, TextureFormat.RGBAFloat, true);
target.SetPixels(source.GetPixels());
target.anisoLevel = source.anisoLevel; target.filterMode = source.filterMode;
target.wrapMode = source.wrapMode; target.Apply();
UnityEngine.Object.FindObjectOfType<NetProperties>().m_downwardDiffuse = target;
// network node
var networkName = "1307021974.UK Roads: Plain 2-Lane 2 Way DYL_Data";
var material = PrefabCollection<NetInfo>.FindLoaded(networkName).m_nodes[0].m_nodeMaterial;
var source = material.GetTexture("_MainTex") as Texture2D;
var target = new Texture2D(source.width, source.height, TextureFormat.RGBAFloat, true);
target.SetPixels(source.GetPixels());
target.anisoLevel = source.anisoLevel; target.filterMode = source.filterMode;
target.wrapMode = source.wrapMode; target.Apply();
UnityEngine.Object.FindObjectOfType<NetProperties>().m_downwardDiffuse = target;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment