Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Created August 26, 2018 12:09
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/314fe9d42bbfb989d241e472b0959ab8 to your computer and use it in GitHub Desktop.
Save ronyx69/314fe9d42bbfb989d241e472b0959ab8 to your computer and use it in GitHub Desktop.
Ingame light effect editing script.
// Ingame light effect editing script.
// Add as many effect changes as necessary.
// Name of the light effect can be found by plopping the prop, and then
// going to [Ctrl+E] Scene Explorer > Tool Controller > Prop Tool >
// m_prefab > m_effects > m_effects.[id] > m_effect
// The light needs to be moved or plopped for the nearby area to update the effects.
BindingFlags b = BindingFlags.Instance | BindingFlags.NonPublic; byte a = 255; LightEffect l = null;
bool color, colorVariations, intensity, range, spotAngle, spotLeaking, blinkType = false;
//----------------------------------------------
l = EffectCollection.FindEffect(
/* LIGHT EFFECT NAME:*/ "Flood Light Short Orange"
) as LightEffect;
// Set to true if you want to change, adjust actual values below.
color = true;
colorVariations = true;
intensity = true;
range = true;
spotAngle = true;
spotLeaking = true;
blinkType = true;
if(color) l.GetType().GetField("m_lightColor", b).SetValue(l,
/* MAIN COLOR:*/ (Color)new Color32(255, 255, 255, a));
if(colorVariations) { Color[] variations = new Color[] { // Color Variations (add more or less if needed)
(Color)new Color32(255, 255, 255, a),
(Color)new Color32(255, 255, 255, a),
(Color)new Color32(255, 255, 255, a)
}; l.m_variationColors = variations; }
if(intensity) l.GetType().GetField("m_lightIntensity", b).SetValue(l,
/* INTENSITY:*/ 3.2f);
if(range) l.GetType().GetField("m_lightRange", b).SetValue(l,
/* RANGE:*/ 27.2f);
if(spotAngle) l.GetType().GetField("m_lightSpotAngle", b).SetValue(l,
/* SPOT ANGLE:*/ 100f);
if(spotLeaking) l.m_spotLeaking =
/* SPOT LEAKING:*/ 0.6f;
if(blinkType) l.m_blinkType =
/* BLINK TYPE:*/ LightEffect.BlinkType.None;
//----------------------------------------------
l = EffectCollection.FindEffect(
/* LIGHT EFFECT NAME:*/ "Street Lamp"
) as LightEffect;
// Set to true if you want to change, adjust actual values below.
color = true;
colorVariations = true;
intensity = true;
range = true;
spotAngle = false;
spotLeaking = true;
blinkType = false;
if(color) l.GetType().GetField("m_lightColor", b).SetValue(l,
/* MAIN COLOR:*/ (Color)new Color32(255, 200, 150, a));
if(colorVariations) { Color[] variations = new Color[] { // Color Variations (add more or less if needed)
(Color)new Color32(255, 200, 130, a),
(Color)new Color32(255, 220, 150, a)
}; l.m_variationColors = variations; }
if(intensity) l.GetType().GetField("m_lightIntensity", b).SetValue(l,
/* INTENSITY:*/ 2.2f);
if(range) l.GetType().GetField("m_lightRange", b).SetValue(l,
/* RANGE:*/ 37.2f);
if(spotAngle) l.GetType().GetField("m_lightSpotAngle", b).SetValue(l,
/* SPOT ANGLE:*/ 100f);
if(spotLeaking) l.m_spotLeaking =
/* SPOT LEAKING:*/ 0.1f;
if(blinkType) l.m_blinkType =
/* BLINK TYPE:*/ LightEffect.BlinkType.None;
//----------------------------------------------
l = EffectCollection.FindEffect(
/* LIGHT EFFECT NAME:*/ "Street Light Medium Road"
) as LightEffect;
// Set to true if you want to change, adjust actual values below.
color = true;
colorVariations = true;
intensity = true;
range = true;
spotAngle = false;
spotLeaking = true;
blinkType = false;
if(color) l.GetType().GetField("m_lightColor", b).SetValue(l,
/* MAIN COLOR:*/ (Color)new Color32(255, 200, 150, a));
if(colorVariations) { Color[] variations = new Color[] { // Color Variations (add more or less if needed)
(Color)new Color32(255, 190, 130, a),
(Color)new Color32(255, 180, 150, a)
}; l.m_variationColors = variations; }
if(intensity) l.GetType().GetField("m_lightIntensity", b).SetValue(l,
/* INTENSITY:*/ 5.2f);
if(range) l.GetType().GetField("m_lightRange", b).SetValue(l,
/* RANGE:*/ 60.0f);
if(spotAngle) l.GetType().GetField("m_lightSpotAngle", b).SetValue(l,
/* SPOT ANGLE:*/ 100f);
if(spotLeaking) l.m_spotLeaking =
/* SPOT LEAKING:*/ 0.1f;
if(blinkType) l.m_blinkType =
/* BLINK TYPE:*/ LightEffect.BlinkType.None;
//----------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment