Created
December 3, 2018 20:19
-
-
Save boformer/1017014acdd9888eab3847272cee9102 to your computer and use it in GitHub Desktop.
Decal Prop Fix Mod
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
using ICities; | |
using UnityEngine; | |
namespace DecalFix | |
{ | |
public class DecalFixMod : LoadingExtensionBase, IUserMod | |
{ | |
public static string marker = new Color(12f / 255, 34f / 255, 56f / 255, 1f).ToString(); | |
public string Name | |
{ | |
get { return "Decal Prop Fix"; } | |
} | |
public string Description | |
{ | |
get { return "Adds support for larger decal sizes and tiling"; } | |
} | |
public override void OnLevelLoaded(LoadMode mode) | |
{ | |
base.OnLevelLoaded(mode); | |
string marker = new Color(12f / 255, 34f / 255, 56f / 255, 1f).ToString(); | |
for (uint i = 0; i < PrefabCollection<PropInfo>.LoadedCount(); i++) | |
{ | |
var prefab = PrefabCollection<PropInfo>.GetLoaded(i); | |
if (prefab == null) continue; | |
if (!prefab.m_isDecal || prefab.m_material == null) continue; | |
if (prefab.m_material.GetColor("_ColorV0").ToString() == marker) | |
{ | |
var color2 = prefab.m_material.GetColor("_ColorV1"); | |
var color3 = prefab.m_material.GetColor("_ColorV2"); | |
var size = new Vector4(color2.r * 255, color2.g * 255, color2.b * 255, 0); | |
var tiling = new Vector4(color3.r * 255, 0, color3.b * 255, 0); | |
prefab.m_material.SetVector("_DecalSize", size); | |
prefab.m_material.SetVector("_DecalTiling", tiling); | |
prefab.m_lodMaterial.SetVector("_DecalSize", size); | |
prefab.m_lodMaterial.SetVector("_DecalTiling", tiling); | |
prefab.m_lodMaterialCombined.SetVector("_DecalSize", size); | |
prefab.m_lodMaterialCombined.SetVector("_DecalTiling", tiling); | |
//Debug.Log($"Fixed decal {prefab.name}. Size: {size}, Tiling: {tiling}"); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment