当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.SetPosition方法代码示例

本文整理汇总了C#中GameObject.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.SetPosition方法的具体用法?C# GameObject.SetPosition怎么用?C# GameObject.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameObject的用法示例。


在下文中一共展示了GameObject.SetPosition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: makeGrid

 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"));
 }
开发者ID:gabrielamboss,项目名称:Ulkoa,代码行数:11,代码来源:GraphMaker.cs

示例2: MakeLine

    private void MakeLine(Networkable a, Networkable b)
    {
        var dir = -Camera.main.transform.forward;

        var line = new GameObject("Line").AddComponent<LineRenderer>();
        line.transform.parent = transform;
        line.SetWidth(0.4f, 0.4f);
        line.SetPosition(0, a.transform.position + dir * 7);
        line.SetPosition(1, b.transform.position + dir * 7);
        line.sharedMaterial = NodeMaterial;
    }
开发者ID:Dyhr,项目名称:LD33-Stealth-Game,代码行数:11,代码来源:HackMode.cs

示例3: MoveUp

 internal static void MoveUp(GameObject sim, float meters)
 {
     sim.SetPosition(
         new Vector3(
             sim.Position.x,
             sim.Position.y + meters,
             sim.Position.z));
 }
开发者ID:markmanching,项目名称:virtual-artisan-s3mods,代码行数:8,代码来源:MoveThings.cs

示例4: MoveForward

 internal static void MoveForward(GameObject sim, float meters)
 {
     sim.SetPosition(
         new Vector3(
             sim.Position.x + (sim.ForwardVector.x * meters),
             sim.Position.y,
             sim.Position.z + (sim.ForwardVector.z * meters)));
 }
开发者ID:markmanching,项目名称:virtual-artisan-s3mods,代码行数:8,代码来源:MoveThings.cs

示例5: DrawOnMove

    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;
        }
    }
开发者ID:Andrefelipe1997,项目名称:LabyrinthGame,代码行数:17,代码来源:CreatingLines.cs

示例6: buildLine

	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);
		}
	}
开发者ID:marouen-lamiri,项目名称:Second-Soul,代码行数:20,代码来源:MiniMap.cs

示例7: MakeMeLaser

	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>();
	}
开发者ID:JulianVallee,项目名称:RTS,代码行数:89,代码来源:GridField.cs

示例8: ParentToSlot

 public static void ParentToSlot(GameObject obj, Slot slot, GameObject parent)
 {
     if (obj != null && parent != null)
     {
         obj.SetPosition(parent.GetPositionOfSlot(slot));
         obj.SetForward(parent.GetForwardOfSlot(slot));                
         obj.ParentToSlot(parent, slot);                
     }
 }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:9,代码来源:DisplayHelper.cs

示例9: drawLine

 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);
 }
开发者ID:autarch-design-team,项目名称:OpenCircuit,代码行数:12,代码来源:AbstractVisualSensor.cs

示例10: RemoveMoveInteractions

        public static void RemoveMoveInteractions(GameObject gameObject, bool resetLocation)
        {
            if (MovedObjects.ContainsKey(gameObject))
            {
                if (resetLocation)
                {
                    LocationVectors vectors;
                    if (MovedObjects.TryGetValue(gameObject, out vectors))
                    {
                        gameObject.SetForward(vectors.ForwardVector);
                        gameObject.SetPosition(vectors.Position);
                    }
                }
                MovedObjects.Remove(gameObject);
            }
            gameObject.RemoveInteractionByType(StopMovingMe.Singleton);

            gameObject.RemoveInteractionByType(TurnLeft.Singleton);
            gameObject.RemoveInteractionByType(TurnAtAngle.Singleton);
            gameObject.RemoveInteractionByType(TurnRight.Singleton);
            gameObject.RemoveInteractionByType(TurnAround.Singleton);
            gameObject.RemoveInteractionByType(TiltFaceUp.Singleton);
            gameObject.RemoveInteractionByType(TiltBack.Singleton);
            gameObject.RemoveInteractionByType(TiltForward.Singleton);
            gameObject.RemoveInteractionByType(TiltFaceDown.Singleton);
            gameObject.RemoveInteractionByType(TiltUserDefined.Singleton);

            gameObject.RemoveInteractionByType(MoveUp.Singleton);
            gameObject.RemoveInteractionByType(MoveUpUserDefined.Singleton);
            gameObject.RemoveInteractionByType(MoveDown.Singleton);
            gameObject.RemoveInteractionByType(MoveDownUserDefined.Singleton);
            gameObject.RemoveInteractionByType(MoveBack.Singleton);
            gameObject.RemoveInteractionByType(MoveBackUserDefined.Singleton);
            gameObject.RemoveInteractionByType(MoveForward.Singleton);
            gameObject.RemoveInteractionByType(MoveForwardUserDefined.Singleton);

            gameObject.RemoveInteractionByType(MoveRight.Singleton);
            gameObject.RemoveInteractionByType(MoveRightUserDefined.Singleton);
            gameObject.RemoveInteractionByType(MoveLeft.Singleton);
            gameObject.RemoveInteractionByType(MoveLeftUserDefined.Singleton);
        }
开发者ID:markmanching,项目名称:virtual-artisan-s3mods,代码行数:41,代码来源:PoseManager.cs

示例11: makeLineGraph

 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"));
 }
开发者ID:gabrielamboss,项目名称:Ulkoa,代码行数:13,代码来源:GraphMaker.cs


注:本文中的GameObject.SetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。