Last active
May 18, 2017 02:58
-
-
Save ronyx69/5cd98cdc051e2e684a835568eba3a28e to your computer and use it in GitHub Desktop.
Replace textures in real time in asset editor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Texture Replacer script by Ronyx69 | |
// ASSET EDITOR, not ingame | |
// Replaces textures in asset editor in real time! | |
// Much thanks to SamsamTS for explaining Actions to me and being helpful. | |
// D, ACI, XYS textures for buildings, props, vehicles and D, XYCA for trees. | |
// Unfortunately CANNOT replace LOD textures. | |
// Technically I know how to replace LOD textures, | |
// but ingame they are combined into one big texture atlas on level load. | |
// I would like to know how to rebuild this atlas ingame, | |
// but I don't know how. Do you know? | |
// Tree LODs work since that's different. | |
// Camera needs to be moved for tree LOD to update. | |
// SCROLL TO BOTTOM, IGNORE THIS (under the hood stuff) | |
Texture2D texture2D; var texturePath = " "; var log = " "; | |
BuildingInfo prefab_building = null; PropInfo prefab_prop = null; | |
TreeInfo prefab_tree = null; VehicleInfo prefab_vehicle = null; | |
Action<string, Material, Material, string> changeTextures = (name, material, material2, type) => | |
{ | |
log=type + "/" + name + ": "; | |
if(type=="props" || type=="buildings" || type=="vehicles") | |
{ | |
texturePath = "textures/" + type + "/" + name + "_D.png"; if (File.Exists(texturePath)) { | |
log=log + "D "; texture2D = new Texture2D(1, 1); | |
texture2D.LoadImage(File.ReadAllBytes(texturePath)); material.SetTexture("_MainTex", texture2D); } | |
texturePath = "textures/" + type + "/" + name + "_ACI.png"; if (File.Exists(texturePath)) { | |
log=log + "ACI "; texture2D = new Texture2D(1, 1); | |
texture2D.LoadImage(File.ReadAllBytes(texturePath)); material.SetTexture("_ACIMap", texture2D); } | |
texturePath = "textures/" + type + "/" + name + "_XYS.png"; if (File.Exists(texturePath)) { | |
log=log + "XYS "; texture2D = new Texture2D(1, 1); | |
texture2D.LoadImage(File.ReadAllBytes(texturePath)); material.SetTexture("_XYSMap", texture2D); } | |
} | |
else if(type=="trees") | |
{ | |
texturePath = "textures/" + type + "/" + name + "_D.png"; if (File.Exists(texturePath)) { | |
log=log + "D "; texture2D = new Texture2D(1, 1); texture2D.LoadImage(File.ReadAllBytes(texturePath)); | |
material.SetTexture("_MainTex", texture2D); material2.SetTexture("_MainTex", texture2D); } | |
texturePath = "textures/" + type + "/" + name + "_XYCA.png"; if (File.Exists(texturePath)) { | |
log=log + "XYCA "; texture2D = new Texture2D(1, 1); texture2D.LoadImage(File.ReadAllBytes(texturePath)); | |
material.SetTexture("_XYCAMap", texture2D); material2.SetTexture("_XYCAMap", texture2D); } | |
} | |
if(log==(type + "/" + name + ": ")) Debug.LogWarning(type + "/" + name + ": NOTHING REPLACED"); | |
else Debug.Log(log); | |
}; | |
Action<string> building = (name) => { prefab_building=ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo; | |
changeTextures(name, prefab_building.m_material, prefab_building.m_lodMaterial, "buildings"); }; | |
Action<string> prop = (name) => { prefab_prop=ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo; | |
changeTextures(name, prefab_prop.m_material, prefab_prop.m_lodMaterial, "props"); }; | |
Action<string> vehicle = (name) => { prefab_vehicle=ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
changeTextures(name, prefab_vehicle.m_material, prefab_vehicle.m_lodMaterial, "vehicles"); }; | |
Action<string> tree = (name) => { prefab_tree=ToolsModifierControl.toolController.m_editPrefabInfo as TreeInfo; | |
changeTextures(name, prefab_tree.m_material, prefab_tree.m_renderMaterial, "trees"); }; | |
// USAGE: | |
// type("name"); | |
// TYPE: | |
// building, prop, tree, vehicle | |
// NAME: | |
// VANILLA: name | |
// LOCAL: filename.Asset Name_Data | |
// WORKSHOP: steamid.Asset Name_Data | |
// TEXTURE LOCATION: gamefolder/textures/type | |
// types are buildings, props, vehicles, trees | |
// TEXTURE NAMING: | |
// name_textureType.png | |
// name is exactly the same name used in the function | |
// texture types = D, ACI, XYS, XYCA(for trees) | |
// EXAMPLES BELOW (delete and add your own) | |
building("816656919.Gran Casino_Data"); | |
prop("Crate 01"); | |
prop("Crate pile"); | |
vehicle("Bus"); | |
tree("754129192.Norfolk Island Pine_Data"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment