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


C# Transform类代码示例

本文整理汇总了C#中Transform的典型用法代码示例。如果您正苦于以下问题:C# Transform类的具体用法?C# Transform怎么用?C# Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Awake

 // Awake
 void Awake()
 {
     myRigidbody = GetComponent<Rigidbody>();
     myRigidbody.maxAngularVelocity = 25f;
     myTransform = GetComponent<Transform>();
     cameraTransform = Camera.main.GetComponent<Transform>();
 }
开发者ID:ifty420,项目名称:Fuel-Truck-Eugene-2,代码行数:8,代码来源:BallMove.cs

示例2: OnCollisionWithEnemy

    protected void OnCollisionWithEnemy(GameObject enemy, float power)
    {
        power *= WeaponPowerMiltiplier;
        enemyTransform = enemy.transform;
        enemyController = enemy.GetComponent<FightEnemyController>();

        if (power < MinForceToHit)
            return;

        // Blood
        newBloodParticle = Instantiate<GameObject>(BloodParticles);
        newBloodParticle.transform.position = enemyTransform.position;
        newBloodParticle.transform.up = (enemyTransform.position - selfTransform.position).normalized;
        Destroy(newBloodParticle, 1);

        // Do damage
        enemyController.DoDamage(Mathf.Clamp(power, MinForceToHit, MaxForceToHit));
        //print(WeaponTypeName + ": " + hitVelocityMagnitude.ToString());

        // Damage Text
        newDamageText = Instantiate<GameObject>(DamageText);
        newDamageTextText = newDamageText.GetComponent<Text>();
        newDamageTextText.rectTransform.SetParent(WorldCanvas, false);
        newDamageTextText.rectTransform.position = enemyTransform.position + new Vector3(0f, 0.5f, 0f); ;
        newDamageTextText.text = string.Format("{0}", power.ToString("F0"));
    }
开发者ID:perfectdaemon,项目名称:ragdoll-arena,代码行数:26,代码来源:WeaponController.cs

示例3: AddChain

	//add chain into chains list
	public void AddChain(Transform chain)
	{
		//if chains list isn't created, create it
		if(chains == null)
			chains = new List<Transform>();

		//if linerenderer isn't added, add it
		if(lineRend == null)
		{
			lineRend = GetComponent<LineRenderer>();

			if(!lineRend)
			{
				lineRend = gameObject.AddComponent<LineRenderer>();
				lineRend.material = ropeMaterial;
			}
		}

		chains.Add (chain);	//add chain into chains list

		//fill LineRenderer component's positions
		lineRend.SetVertexCount (chains.Count);
		lineRend.SetPosition (chains.Count - 1, chains[chains.Count - 1].position);

		startChainCount = chains.Count;
	}
开发者ID:diglungdig,项目名称:AquaSkiing,代码行数:27,代码来源:UseLineRenderer.cs

示例4: CrossToTarget

    public static float CrossToTarget(Transform thisXform, Vector3 targetPos)
	{
		Vector3 nominalPos = thisXform.position;
		Vector3 DirToTarget = (targetPos - nominalPos).normalized;
		Vector3 ForwardDir = thisXform.forward.normalized;
		return Vector3.Cross(ForwardDir, DirToTarget).y;
	}
开发者ID:liliankasem,项目名称:DroneControl,代码行数:7,代码来源:GeometryClass.cs

示例5: DrawLayoutOutline

	void DrawLayoutOutline(Transform t) {
		var layout = t.GetComponent<tk2dUILayout>();
		if (layout != null) {
			Vector3[] p = new Vector3[] {
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
			};
			for (int i = 0; i < p.Length; ++i) p[i] = t.TransformPoint(p[i]);
			Handles.color = Color.magenta;
			Handles.DrawPolyLine(p);

			var sizer = t.GetComponent<tk2dUILayoutContainerSizer>();
			if (sizer != null) {
				Handles.color = Color.cyan;
				float arrowSize = 0.3f * HandleUtility.GetHandleSize(p[0]);
				if (sizer.horizontal) {
					Handles.ArrowCap(0, (p[0] + p[3]) * 0.5f, Quaternion.LookRotation(p[1] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[1] + p[2]) * 0.5f, Quaternion.LookRotation(p[0] - p[1]), arrowSize);
				} else {
					Handles.ArrowCap(0, (p[0] + p[1]) * 0.5f, Quaternion.LookRotation(p[3] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[2] + p[3]) * 0.5f, Quaternion.LookRotation(p[0] - p[3]), arrowSize);
				}
			}
		}

		for (int i = 0; i < t.childCount; ++i)
			DrawLayoutOutline(t.GetChild(i));
	}
开发者ID:AtwoodDeng,项目名称:GGJ2015,代码行数:31,代码来源:tk2dUILayoutEditor.cs

示例6: Shot

	public override void Shot (Vector3 shotOrigin, GameObject target, Transform cannonTransform)
	{
		//if(WeaponReady)
		{
			WeaponReady = false;
			
			Vector3 shotDirection = cannonTransform.forward;
			
			// Note: In a real project, you must not instante many objects a runtime, instead, you may consider creating a shoot pool.
			Rigidbody newBullet = Instantiate(bullet,shotOrigin,cannonTransform.rotation) as Rigidbody;
			
			newBullet.AddForce(shotForce*shotDirection);
			
			if(shotSound != null && shotAudioSource != null)
				shotAudioSource.PlayOneShot(shotSound);
			
			if(weaponParticleSystem != null)
				weaponParticleSystem.Play();
			
			StartCoroutine(LightFlash());
			
			// Reset timmer
			timeCounter = 0f;
		}
	}
开发者ID:EvilAbyss,项目名称:Wulfram,代码行数:25,代码来源:ExampleWeapon.cs

示例7: CalculateAbsoluteWidgetBounds

    /// <summary>
    /// Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
    /// </summary>
    public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
    {
        UIWidget[] widgets = trans.GetComponentsInChildren<UIWidget>() as UIWidget[];

        Bounds b = new Bounds(trans.transform.position, Vector3.zero);
        bool first = true;

        foreach (UIWidget w in widgets)
        {
            Vector2 size = w.relativeSize;
            Vector2 offset = w.pivotOffset;
            float x = (offset.x + 0.5f) * size.x;
            float y = (offset.y - 0.5f) * size.y;
            size *= 0.5f;

            Transform wt = w.cachedTransform;
            Vector3 v0 = wt.TransformPoint(new Vector3(x - size.x, y - size.y, 0f));

            // 'Bounds' can never start off with nothing, apparently, and including the origin point is wrong.
            if (first)
            {
                first = false;
                b = new Bounds(v0, Vector3.zero);
            }
            else
            {
                b.Encapsulate(v0);
            }

            b.Encapsulate(wt.TransformPoint(new Vector3(x - size.x, y + size.y, 0f)));
            b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y - size.y, 0f)));
            b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y + size.y, 0f)));
        }
        return b;
    }
开发者ID:quiker,项目名称:hexagon,代码行数:38,代码来源:NGUIMath.cs

示例8: TryGiveItem

	/// <summary>
	/// tries to award an item to a recipient by transform, item type
	/// and amount
	/// </summary>
	public static bool TryGiveItem(Transform recipient, vp_ItemType itemType, int amount)
	{

		if (recipient == null)
		{
			Debug.LogError("Error (" + Instance + ") Recipient was null.");
			return false;
		}

		vp_Inventory inventory;
		if (!m_RecipientInventories.TryGetValue(recipient, out inventory))
		{
			inventory = vp_TargetEventReturn<vp_Inventory>.SendUpwards(recipient, "GetInventory");
			m_RecipientInventories.Add(recipient, inventory);
		}

		if (inventory == null)
		{
			Debug.LogError("Error (" + Instance + ") Failed to find an enabled inventory on '" + recipient + "'.");
			return false;
		}

		if (TryMatchExistingItem(inventory, recipient, itemType, amount))
			return true;

		return TryGiveItemAsNew(recipient, itemType, amount);
	
	}
开发者ID:Bakiet,项目名称:EvilAwakening,代码行数:32,代码来源:vp_MPItemList.cs

示例9: StateAgro

 public StateAgro(NavMeshAgent _agent, Vector3 _point, Transform _transform, ref StateSet _set)
 {
     set = _set;
     transform = _transform;
     agent = _agent;
     point = _point;
 }
开发者ID:OSW-team,项目名称:Project-4,代码行数:7,代码来源:StateMachine.cs

示例10: Start

 // Use this for initialization
 void Start()
 {
     player = PlayerController.MyTransform;
     candig = false;
     diggableItem.SetActive(false);
     digtime = 0f;
 }
开发者ID:stuarrt,项目名称:StarCrossing,代码行数:8,代码来源:DigMarker.cs

示例11: AddChildren

 private void AddChildren(Transform parent, List<Transform> list)
 {
     list.Add (parent);
     foreach (Transform t in parent) {
         AddChildren (t, list);
     }
 }
开发者ID:kahojon,项目名称:NewApplication,代码行数:7,代码来源:Ragdoll.cs

示例12: Start

    // Use this for initialization
    void Start()
    {
        //make a reference with the transform component
        this._transform = gameObject.GetComponent<Transform>();
        this.Reset();

    }
开发者ID:dpandya76,项目名称:2D-Shooter-Horizontal,代码行数:8,代码来源:SkyController.cs

示例13: Awake

 private void Awake()
 {
     button = transform.FindChild("Button");
     thebase = transform.FindChild("Base");
     startScale = button.localScale;
     targetScale = thebase.localScale;
 }
开发者ID:EJBQ,项目名称:Bae-Zeus-X,代码行数:7,代码来源:LongPress_Button.cs

示例14: Start

 void Start()
 {
     _t = transform;
     _animator = GetComponent<Animator>();
     _controller = GetComponent<CharacterController>();
     _rigidbody = GetComponent<Rigidbody>();
 }
开发者ID:choang05,项目名称:Puzzle-2,代码行数:7,代码来源:SrpgcMouseMovementController.cs

示例15: Awake

    // Use this for initialization
    void Awake()
    {
        player = GameObject.FindGameObjectWithTag ("Player").transform;
        playerOrgin = player.position;

        path2 = new []{ new Vector3(10.0f,20.0f,40f), new Vector3(10f,10f,20f),
            playerOrgin, new Vector3(0f,10f,-10f), new Vector3( 0f, -5f, -20f), new Vector3(10f,-10f,5f),
            new Vector3(5f,5f,15f), new Vector3(0f,20f,20f)};

        path3 = new []{ new Vector3(30.0f,6.0f,60f), new Vector3(9f,40f,40f),
            new Vector3(15.2f,2f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, 7f, -30f), new Vector3(16f,4f, 5f)};

        path4 = new []{ new Vector3(20.0f,30.0f,60f), new Vector3(5f,70f,40f),
            new Vector3(28.2f,21f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, 7f, -30f), new Vector3(16f,4f, 5f)};

        path5 = new []{ new Vector3(20.0f,30.0f,60f), new Vector3(5f,-70f,30f),
            new Vector3(11.2f,16f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, -17f, -30f), new Vector3(16f,4f, 5f)};

        aiShip = FindObjectOfType <Rigidbody> ();
        launcher = GetComponent<MLauncher> ();

        path = path2;
        target = path[0];
        bound = new Bounds (path[0], new Vector3(1f,1f,1f));
    }
开发者ID:CodeoGenic,项目名称:Asteroid_Rift,代码行数:26,代码来源:FollowPath.cs


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