How can i add my custom game component to a player camera?
It's possible?
Code:using System; using UnityEngine; using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Libraries.Covalence;namespace Oxide.Plugins { public class GLLine : MonoBehaviour { private Material whLineMaterial; void CreateLineMaterial() { if (!whLineMaterial) { whLineMaterial = new Material("Shader \"Lines/Colored Blended\" {" + "SubShader { Pass { " + " Blend SrcAlpha OneMinusSrcAlpha " + " ZWrite Off Cull Off Fog { Mode Off } " + " ZTest Always " + " BindChannels {" + " Bind \"vertex\", vertex Bind \"color\", color }" + "} } }"); whLineMaterial.hideFlags = HideFlags.HideAndDontSave; whLineMaterial.shader.hideFlags = HideFlags.HideAndDontSave; } } void OnRenderObject() { // just test line DrawGLLine(this.transform.position, this.transform.position + this.transform.forward * 2); } public void DrawGLLine(Vector3 P1, Vector3 P2) { CreateLineMaterial(); whLineMaterial.SetPass(0); GL.PushMatrix(); GL.Begin(GL.LINES); GL.Color(Color.red); GL.Vertex3(P1.x, P1.y, P2.z); GL.Vertex3(P2.x, P2.y, P2.z); GL.End(); GL.PopMatrix(); } } [Info("WallHack", "GodOfGods/justtest", "1.3.1")] [Description("WallHack")] class WallHack : CovalencePlugin { #if HURTWORLD void OnPlayerInit(PlayerSession session) { // if (!IsAdmin(session.SteamId.ToString())) return; Puts(session.Name + " glline init "); CharacterMotorSimple motor = session.WorldPlayerEntity.GetComponent<CharacterMotorSimple>(); motor.PlayerCamera.gameObject.AddComponent<GLLine>(); } #endif bool IsAdmin(string id) => permission.UserHasGroup(id, "admin"); } }
Create a new game component
Discussion in 'Hurtworld Development' started by GodOfGods, May 12, 2016.