Last active
June 5, 2018 14:40
-
-
Save ronyx69/c11629a4bd96c9bba13348e0fad7e763 to your computer and use it in GitHub Desktop.
Source code for the AnimUV Params mod.
This file contains hidden or 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
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