Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active June 5, 2018 14:40
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/c11629a4bd96c9bba13348e0fad7e763 to your computer and use it in GitHub Desktop.
Save ronyx69/c11629a4bd96c9bba13348e0fad7e763 to your computer and use it in GitHub Desktop.
Source code for the AnimUV Params mod.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICities;
using UnityEngine;
namespace AnimUV
{
public class AnimUVMod : LoadingExtensionBase, IUserMod
{
public string Name => "AnimUV Params";
public string Description => "Loads AnimUV parameters.";
public override void OnLevelLoaded(LoadMode mode)
{
base.OnLevelLoaded(mode);
ApplyParams();
}
public override void OnLevelUnloading()
{
base.OnLevelUnloading();
}
private void ApplyParams()
{
for (uint i = 0; i < PrefabCollection<PropInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<PropInfo>.GetLoaded(i);
if (prefab == null) continue;
if (prefab.m_mesh.name.Contains("AnimUV") == true)
{
string[] floats = prefab.m_mesh.name.Split(' ');
var vec = new Vector4(Convert.ToSingle(floats[1]), Convert.ToSingle(floats[2]), Convert.ToSingle(floats[3]), Convert.ToSingle(floats[4]));
prefab.m_material.SetVector("_RollParams0", vec);
}
}
for (uint i = 0; i < PrefabCollection<VehicleInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<VehicleInfo>.GetLoaded(i);
if (prefab == null) continue;
if (prefab.m_subMeshes.Length > 1)
{
for (uint j = 0; j < prefab.m_subMeshes.Length; j++)
{
if (prefab.m_subMeshes[j].m_subInfo != null)
{
if (prefab.m_subMeshes[j].m_subInfo.m_mesh.name.Contains("AnimUV") == true)
{
string[] floats = prefab.m_subMeshes[j].m_subInfo.m_mesh.name.Split(' ');
var vec = new Vector4(Convert.ToSingle(floats[1]), Convert.ToSingle(floats[2]), Convert.ToSingle(floats[3]), Convert.ToSingle(floats[4]));
prefab.m_subMeshes[j].m_subInfo.m_material.SetVector("_RollParams0", vec);
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment