Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active April 12, 2017 22:08
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/0555ac4160b704a6bcd25a2082584bce to your computer and use it in GitHub Desktop.
Save ronyx69/0555ac4160b704a6bcd25a2082584bce to your computer and use it in GitHub Desktop.
A first draft at converting a vehicle to a prop ingame.
var vehicle = PrefabCollection<VehicleInfo>.FindLoaded("Sedan"); //get the vehicle
var prop = PrefabCollection<PropInfo>.FindLoaded("Cargo container"); //get the prop
prop.m_mesh=vehicle.m_mesh; //apply vehicle mesh to the prop
prop.m_material.SetTexture("_MainTex", vehicle.m_material.GetTexture("_MainTex")); //apply vehicle diffuse to prop
prop.m_material.SetTexture("_XYSMap", vehicle.m_material.GetTexture("_XYSMap")); //apply vehicle XYS to prop
Texture2D aci; aci = new Texture2D(1, 1); //make new empty texture
aci = vehicle.m_material.GetTexture("_ACIMap"); //WRONG!!! ACI should be made unique/instantiated!? idk
//pixel loop to change all illumination pixels to white (no illumination)
//won't work because non-readable texture, probably will work with custom assets
//but still the ACI texture will change on the vehicle as well so...
//the aci on the prop needs to become unique/instantiated or whatever it's called, idk how to do it
Color px;
for (int i = 0; i < aci.width; i++)
{
for (int j = 0; j < aci.height; j++)
{
px=aci.GetPixel(i, j);
px.b=1;
aci.SetPixel(i, j, px);
}
}
aci.Apply();
prop.m_material.SetTexture("_ACIMap", aci); //should apply the new ACI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment