Skip to content

Instantly share code, notes, and snippets.

@iwanPlays
Created August 3, 2020 09:35
Show Gist options
  • Select an option

  • Save iwanPlays/4435ea312f309f2350427e40c7dd9a4c to your computer and use it in GitHub Desktop.

Select an option

Save iwanPlays/4435ea312f309f2350427e40c7dd9a4c to your computer and use it in GitHub Desktop.
Receiver 2 Tritium Sights mod
/* Receiver 2 Tritium Sights mod
1 model_10
-"barrel"
-"frame"
2 colt_detective
-"barrel"
-"frame"
3 colt_1911_a1
-"slide" - "front_sight"
-"slide" - "rear_sight"
4 glock17
-"slide" - "sight_front"
-"slide" - "sight_rear"
5 beretta_m9
-"slide"
-"slide" - "rear_sight"
6 hi_point_c9
-"slide"
-"slide" - "rear_sight"
7 sig226
-"slide" - "Front_Sight"
-"slide" - "Rear_Sight"
8 desert_eagle
-"barrel" - "front_sight"
-"slide" - "rear_sight"
9 colt_saa
-"barrel"
-"frame"
*/
public new void Start()
{
Debug.Log(" === Tritium Mod Start === ");
//Debug.Log("gun name '" + this.gameObject.name +"'");
if(this.gameObject.name.Contains("hi_point_c9"))
{
GameObject front = this.transform.FindChild("slide").gameObject;
GameObject rear = this.transform.FindChild("slide").FindChild("rear_sight").gameObject;
GameObject s1 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject s2 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject s3 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
Destroy(s1.GetComponent<SphereCollider>());
Destroy(s2.GetComponent<SphereCollider>());
Destroy(s3.GetComponent<SphereCollider>());
s1.transform.parent = front.transform;
s2.transform.parent = rear.transform;
s3.transform.parent = rear.transform;
s1.transform.localPosition = new Vector3(0.003f, 0f, 0.022f);
s2.transform.localPosition = new Vector3(0.003f, 0.0025f, 0.002f);
s3.transform.localPosition = new Vector3(0.003f, -0.0025f, 0.002f);
Vector3 dotSize = new Vector3(0.001f,0.001f,0.001f);
s1.transform.localScale = dotSize;
s2.transform.localScale = dotSize;
s3.transform.localScale = dotSize;
//Material
Material tri = new Material(Shader.Find("Standard"));
Material tri2 = new Material(Shader.Find("Standard"));
Material tri3 = new Material(Shader.Find("Standard"));
tri.name = "triGreen";
tri2.name = "triBlue";
tri3.name = "triRed";
tri.SetColor("_EmissionColor", Color.green);
tri.EnableKeyword("_EMISSION");
tri2.SetColor("_EmissionColor", Color.blue);
tri2.EnableKeyword("_EMISSION");
tri3.SetColor("_EmissionColor", Color.red);
tri3.EnableKeyword("_EMISSION");
s1.GetComponent<Renderer>().material = tri;
s2.GetComponent<Renderer>().material = tri;
s3.GetComponent<Renderer>().material = tri;
}
if(this.gameObject.name.Contains("colt_1911_a1"))
{
GameObject front = this.transform.FindChild("slide").FindChild("front_sight").gameObject;
GameObject rear = this.transform.FindChild("slide").FindChild("rear_sight").gameObject;
GameObject s1 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject s2 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject s3 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
Destroy(s1.GetComponent<SphereCollider>());
Destroy(s2.GetComponent<SphereCollider>());
Destroy(s3.GetComponent<SphereCollider>());
s1.transform.parent = front.transform;
s2.transform.parent = rear.transform;
s3.transform.parent = rear.transform;
s1.transform.localPosition = new Vector3(0.003f, 0f, 0.002f);
s2.transform.localPosition = new Vector3(0.003f, 0.0025f, 0.002f);
s3.transform.localPosition = new Vector3(0.003f, -0.0025f, 0.002f);
Vector3 dotSize = new Vector3(0.001f,0.001f,0.001f);
s1.transform.localScale = dotSize;
s2.transform.localScale = dotSize;
s3.transform.localScale = dotSize;
//Material
Material tri = new Material(Shader.Find("Standard"));
Material tri2 = new Material(Shader.Find("Standard"));
Material tri3 = new Material(Shader.Find("Standard"));
tri.name = "triGreen";
tri2.name = "triBlue";
tri3.name = "triRed";
tri.SetColor("_EmissionColor", Color.green);
tri.EnableKeyword("_EMISSION");
tri2.SetColor("_EmissionColor", Color.blue);
tri2.EnableKeyword("_EMISSION");
tri3.SetColor("_EmissionColor", Color.red);
tri3.EnableKeyword("_EMISSION");
s1.GetComponent<Renderer>().material = tri;
s2.GetComponent<Renderer>().material = tri;
s3.GetComponent<Renderer>().material = tri;
}
Debug.Log(" === Tritium Mod End === ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment