void OnEnable() { Go = false; ProjectionSurface = GameObject.Find ("MainPanel"); ProjectionCamera = GameObject.Find ("MainPanelCamera").GetComponent<Camera>(); //initializes VectorLine object VectorLine.SetCamera3D(ProjectionCamera); lineTexture = (Texture) Resources.Load("ThinLine"); vectorLine = VectorLine.SetLine3D(Color.black, new Vector3[2]); vectorLine.lineWidth = 5f; vectorLine.material = new Material(Shader.Find("GUI/Text Shader")); vectorLine.material.mainTexture = lineTexture; stickySender = ProjectionCamera.gameObject.GetComponent<StickySender> (); stickySender.lineHit += lineHit; if (type == Type.Line) //Now Obsolete LineRenderer Code { //Use Vectrosity and VectorLines //LineColor = new Color (0f, 1f, 0f, 1f); //GetComponent<LineRenderer>().SetWidth(0.1f, 0.1f); //GetComponent<LineRenderer>().material = new Material(Shader.Find("Particles/Alpha Blended")); foreach (Transform child in transform) { //if (child.GetComponent<LineRenderer>() != null) //{ //line = child.GetComponent<LineRenderer>(); //} if(child.GetComponent<SpriteRenderer>() != null) { arrowHead = child.GetComponent<SpriteRenderer>(); lineCollider = GetComponent<BoxCollider>(); } } //if (line != null) //{ //line.material = new Material(Shader.Find("Particles/Alpha Blended")); //} } }
private void lineHit(GameObject _hit, StickySender.ButtonClicked _button) { if (this == null) return; if (_hit == null || _hit != gameObject) return; if (_button == StickySender.ButtonClicked.Left) { } if (_button == StickySender.ButtonClicked.Right) { var position = Camera.main.ScreenToWorldPoint(Input.mousePosition); position.x += 1.0f; if (type == Type.Line) { Instantiate(circlePopupLine, position, Quaternion.identity); CircleMenuButton.lineScript = this; } else if (type == Type.Handle) { Instantiate(circlePopupHandle, position, Quaternion.identity); CircleMenuButton.lineScript = this; } } }