Example #1
0
 // Following method creates new line for MagnifyGlass's border
 private LineRenderer getLine()
 {
     LineRenderer line = new GameObject("Line").AddComponent<LineRenderer>();
     line.material = new Material(Shader.Find("Diffuse"));
     line.SetVertexCount(2);
     line.SetWidth(0.2f, 0.2f);
     line.SetColors(Color.black, Color.black);
     line.useWorldSpace = false;
     return line;
 }
Example #2
0
 private void makeGrid(Vector3 begin, Vector3 end)
 {
     LineRenderer line = new GameObject().AddComponent<LineRenderer>();
     line.transform.parent = this.transform.parent;
     line.SetWidth(0.01F, 0.01F);
     line.SetColors(lightBlue, lightBlue);
     line.SetPosition(0, begin);
     line.SetPosition(1, end);
     line.SetVertexCount(2);
     line.material = new Material(Shader.Find("Particles/Additive"));
 }
    void DrawOnMove()
    {
        //Se os valores X ou Y da variavel MouseLastPosition(Posiçao antiga do mouse) forem diferentes dos valores X ou Y da variavel MouseActualPosition(Posiçao atual do mouse), entao o mouse se moveu
        if(MouseLastPosition.x != MouseActualPosition.x || MouseLastPosition.y != MouseActualPosition.y)
        {
            LineRenderer Line = new GameObject("Line").AddComponent<LineRenderer>();
            Line.transform.parent = GameObject.Find("LineMother").transform;
            Line.material = LineColor;
            Line.SetVertexCount(2);
            Line.SetWidth(0.1f,0.1f);
            Line.SetPosition(0,Camera.main.ScreenToWorldPoint(new Vector3(MouseLastPosition.x, MouseLastPosition.y, ZPosition)));
            Line.SetPosition(1,Camera.main.ScreenToWorldPoint(new Vector3(MouseActualPosition.x, MouseActualPosition.y, ZPosition)));

            //Igualando a posiçao antiga do mouse com a atual, para caso ele se mova de novo, a comparaçao seja correta
            MouseLastPosition = Input.mousePosition;
        }
    }
Example #4
0
	public static void buildLine(Vector3 start, Vector3 end){
		LineRenderer line = new GameObject ("Line").AddComponent<LineRenderer> ();
		//apparently I should use this as a default material, but it didn't work so I used some arbitrary material
		//line.material = new Material(Shader.Find("Particles/Additive"));
		line.material = material;
		line.gameObject.layer = LayerMask.NameToLayer ("Minimap");
		line.material.SetColor ("colour", Color.black);
		line.castShadows = false;
		line.receiveShadows = false;
		line.transform.parent = GameObject.Find("lines").transform;
		line.SetWidth(1.0f, 1.0f);
		line.SetVertexCount(2);
		line.SetPosition(0, start);
		line.SetPosition (1, end);
		string positions = start.x.ToString () + "," + start.y.ToString () + "," + start.z.ToString () + "," + end.x.ToString () + "," + end.y.ToString () + "," + end.z.ToString ();
		if (Network.isServer) {
			ClientNetwork client = (ClientNetwork) GameObject.FindObjectOfType(typeof(ClientNetwork));
			client.startClientLines (positions);
		}
	}
Example #5
0
	public void MakeMeLaser(Color color)
	{
		/*
		foreach(GameObject go in GameObject.FindObjectsOfType(typeof(GameObject)))
		{
			if(go.name == "lineUP")
			{
				GameObject.Destroy (go);
			}
		}
		// Set LineRenderer InitializationGameObject yourName = new GameObject();
		LineRenderer lineRenderer = new GameObject("lineUP").AddComponent<LineRenderer>();
		lineRenderer.sharedMaterial = new Material(Shader.Find("Particles/Additive"));
		lineRenderer.SetColors(Color.red, Color.red);
		lineRenderer.SetWidth(1f, 1f);
		lineRenderer.SetVertexCount(2);
		
		// We need no Shadows
		lineRenderer.castShadows = false;
		lineRenderer.receiveShadows = false;
		Debug.Log ("Raw posX: " + posX + "Raw posX: " + posY);

		float worldX = posX * 4;
		float worldZ = posY * 4;

		Vector3 pos = new Vector3(worldX + 2, 0, worldZ + 2);
		lineRenderer.SetPosition(0, pos);

		pos = new Vector3(worldX + 2, 800, worldZ + 2);
		lineRenderer.SetPosition(1, pos);
		*/
		// Make 
		//GameController.instance.treeGroupController.AddTreeGroup(posX, posY);

		RaycastHit hit;

		// Set LineRenderer InitializationGameObject yourName = new GameObject();
		LineRenderer lineRenderer = new GameObject("lineUP").AddComponent<LineRenderer>();
		lineRenderer.sharedMaterial = new Material(Shader.Find("Particles/Additive"));
		lineRenderer.SetColors(color, color);
		lineRenderer.SetWidth(0.2f, 0.2f);
		lineRenderer.SetVertexCount(5);
		
		// We need no Shadows
		lineRenderer.castShadows = false;
		lineRenderer.receiveShadows = false;
		
		float worldX = posX * 4;
		float worldZ = posY * 4;
		Vector3 pos;
		Ray ray = new Ray(new Vector3(worldX, 10, worldZ), Vector3.up);
		if (Physics.Raycast (ray, out hit)) 
		{
			pos = new Vector3(worldX, hit.point.y + 1, worldZ);
			lineRenderer.SetPosition(0, pos);
		}


		ray = new Ray(new Vector3(worldX + 4, 10, worldZ), Vector3.up);
		if (Physics.Raycast (ray, out hit)) 
		{
			pos = new Vector3(worldX + 4, hit.point.y + 1, worldZ);
			lineRenderer.SetPosition(1, pos);
		}

		ray = new Ray(new Vector3(worldX + 4, 10, worldZ + 4), Vector3.up);
		if (Physics.Raycast (ray, out hit)) 
		{
			pos = new Vector3(worldX + 4, hit.point.y + 1, worldZ + 4);
			lineRenderer.SetPosition(2, pos);
		}

		ray = new Ray(new Vector3(worldX, 10, worldZ + 4), Vector3.up);
		if (Physics.Raycast (ray, out hit)) 
		{
			pos = new Vector3(worldX, hit.point.y + 1, worldZ + 4);
			lineRenderer.SetPosition(3, pos);
		}

		ray = new Ray(new Vector3(worldX, 10, worldZ), Vector3.up);
		if (Physics.Raycast (ray, out hit)) 
		{
			pos = new Vector3(worldX, hit.point.y + 1, worldZ);
			lineRenderer.SetPosition(4, pos);
		}
	

		lineRenderer.gameObject.AddComponent<SelectionLine>();
	}
Example #6
0
    private LineRenderer createLine()
    {
        LineRenderer line;

        line = new GameObject("Line").AddComponent<LineRenderer>();

        line.SetWidth(0.06f, 0.06f);

        line.material = this.material;

        line.material.SetColor("_Color", new Color(0.8824f, 0.1843f, 0.0413f));

        line.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        line.SetColors(new Color(0.8824f, 0.1843f, 0.0413f), new Color(0.8824f, 0.1843f, 0.0413f));

        line.SetVertexCount(2);

        return line;
    }
 protected void drawLine(Vector3 start, Vector3 end, Color color)
 {
     LineRenderer line = new GameObject("Line ").AddComponent<LineRenderer>();
     line.SetWidth(0.025F, 0.025F);
     line.SetColors(color, color);
     line.SetVertexCount(2);
     line.SetPosition(0, start);
     line.SetPosition(1, end);
     line.material.shader = (Shader.Find("Unlit/Color"));
     line.material.color = color;
     lines.Add(line.gameObject);
 }
Example #8
0
	// Draw a single line.
	void DrawLine(int lineMultiplicator, Axis axis)
	{
		// Set LineRenderer InitializationGameObject yourName = new GameObject();
		LineRenderer lineRenderer = new GameObject("line").AddComponent<LineRenderer>();
		lineRenderer.sharedMaterial = lineMaterial;
		lineRenderer.SetColors(c1, c2);
		lineRenderer.SetWidth(beginWidth, endWidth);
		lineRenderer.SetVertexCount(lengthOfLineRenderer / lineSegmentLenght + 1);
		
		// We need no Shadows
		lineRenderer.castShadows = false;
		lineRenderer.receiveShadows = false;
		
		// Create LineVertexes
		InstantiateLine(lineMultiplicator, lineRenderer, axis);
		
	}
Example #9
0
 private void makeLineGraph(Vector3 begin, Vector3 end)
 {
     //makePoint(begin);
    // makePoint(end);
     LineRenderer line = new GameObject().AddComponent<LineRenderer>();
     line.transform.parent = this.transform.parent;
     line.SetWidth(0.05F, 0.05F);
     line.SetColors(Color.green, Color.green);
     line.SetPosition(0, begin);
     line.SetPosition(1, end);
     line.SetVertexCount(2);
     line.material = new Material(Shader.Find("Particles/Additive"));
 }