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


C# Transform.FindChild方法代码示例

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


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

示例1: CreateTiles

	private void CreateTiles(Transform parent)
	{
		if(parent.FindChild(TileParentName) != null) GameObject.DestroyImmediate(parent.FindChild(TileParentName).gameObject);

		GameObject TileParent = new GameObject();
		GameObject AvailableTileParent = new GameObject();
		GameObject ImpossibleTileParent = new GameObject();

		TileParent.name = TileParentName;
		AvailableTileParent.name = AvailableTileParentName;
		ImpossibleTileParent.name = ImpossibleTileParentName;

		TileParent.transform.parent = parent;
		AvailableTileParent.transform.parent = TileParent.transform;
		ImpossibleTileParent.transform.parent = TileParent.transform;

		TileParent.transform.localPosition = Vector3.zero;
		AvailableTileParent.transform.localPosition = Vector3.zero;
		ImpossibleTileParent.transform.localPosition = Vector3.zero;

		TileParent.transform.localScale = Vector3.one;
		AvailableTileParent.transform.localScale = Vector3.one;
		ImpossibleTileParent.transform.localScale = Vector3.one;

		for(int wIndex = 0; wIndex < WidthCount; wIndex++)
		{
			for(int hIndex = 0; hIndex < HeightCount; hIndex++)
			{
				SetTile(wIndex, hIndex, AvailableTileParent.transform, ImpossibleTileParent.transform);
			}
		}

		if(WidthCount%2 == 0)TileParent.transform.localPosition += Vector3.left*TileSize*0.5f;
		if(HeightCount%2 == 0)TileParent.transform.localPosition += Vector3.back*TileSize*0.5f;
	}
开发者ID:jinbhum,项目名称:tiny-factory-tower-defence,代码行数:35,代码来源:CustomMapTileWindow.cs

示例2: Start

	// Use this for initialization
	void Start () {
		totalHealth = 10;
		currentHealth = 10;

		/* Add generation of these children depending
		 * on the numberof totalHealth.
		 * Use division of total amount of hearts and the length
		 * of the layer before it to give offsets.
		 */


		healthBar = transform.FindChild("HealthBar");
		heart1 = healthBar.FindChild ("0,1,2");
		heart2 = healthBar.FindChild ("3,4");
		heart3 = healthBar.FindChild ("5,6");
		heart4 = healthBar.FindChild ("7,8");
		heart5 = healthBar.FindChild ("9,10");

		GameObject playerP1 = GameObject.Find ("P1");
		GameObject playerP2 = GameObject.Find ("P2");

		foreach (Transform child in playerP1.transform) {
			if (child.name == "Player_animated") {
				animatorP1Body = child.GetChild(0).GetComponent<Animator> ();
			}
		}
		animatorP1Slime = GameObject.Find("Player_blue_slime").GetComponent<Animator> ();

		foreach (Transform child in playerP2.transform) {
			if (child.name == "Player_animated") {
				animatorP2Body = child.GetChild(0).GetComponent<Animator> ();
			}
		}
		animatorP2Slime = GameObject.Find("Player_yellow_slime").GetComponent<Animator> ();
	}
开发者ID:canadianbif,项目名称:Symbiosis,代码行数:36,代码来源:HealthManager.cs

示例3: OnEnable

    void OnEnable()
    {
        my = gameObject.GetComponent <Transform>();
        playerManager = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren<PlayerManager>();

        arrowPath = "Weapon/Arrow/Arrow" + playerManager.a.ToString();
        starPath = "Weapon/Star/Star" + playerManager.a.ToString();

        arrowBullet = my.FindChild("Arrow");
        starBullet = my.FindChild("Star");

        arrowBullet.GetComponent<SpriteRenderer>().sprite =
            Resources.Load<Sprite>(arrowPath);
        starBullet.GetComponent<SpriteRenderer>().sprite =
            Resources.Load<Sprite>(starPath);

        starBullet.gameObject.SetActive(false);
        arrowBullet.gameObject.SetActive(false);

        if (playerManager.wState == WeaponState.arrow)
        {
            arrowBullet.gameObject.SetActive(true);
        }
        else if (playerManager.wState == WeaponState.star)
        {
            starBullet.gameObject.SetActive(true);
        }
    }
开发者ID:ChunggiLee,项目名称:TapRPG,代码行数:28,代码来源:BulletMove.cs

示例4: Initiate

    public void Initiate(Manager_Row _manager, float _maxHeight)
    {
        manager   = _manager;
        maxHeight = _maxHeight;

        mTransform  = transform;
        mColliders  = mTransform.FindChild("Colliders");
        mNodes      = mTransform.FindChild("Nodes");
        rowCollider = mColliders.GetComponent<RowCollider>();


        startPosition = mTransform.position;

        // Get all nodes
        TotalNodes = mNodes.childCount;       
        for (int i = 0; i < TotalNodes; i++)
        {
            Node node  = new Node();
            node.mNode = mNodes.GetChild(i).gameObject;
            node.pos_x = mNodes.GetChild(i).position.x;
            node.Id = i;

            Nodes.Add(node);
        }

        // Set up colliders
       rowCollider.Initiate(Nodes);

        // Deactivate row
        isActive = false;
    }
开发者ID:Kurukshetran,项目名称:Gravity,代码行数:31,代码来源:Row.cs

示例5: ChangeSide

    private void ChangeSide(Side newSide)
    {
        switch (newSide)
        {
            case Side.Left:
                LeftObjectsContainer.gameObject.SetActive(true);
                RightObjectsContainer.gameObject.SetActive(false);
                container = LeftObjectsContainer;
                break;

            case Side.Right:
                LeftObjectsContainer.gameObject.SetActive(false);
                RightObjectsContainer.gameObject.SetActive(true);
                container = RightObjectsContainer;
                break;

            default: throw new System.NotImplementedException();
        }

        turnTowardsText = container.FindChild("Turn Towards");
        lookAboveText = container.FindChild("Look Above");
        nodText = container.FindChild("Nod");
        throwText = container.FindChild("Throw");

        ChangeState(States.TurnTowardsBarrel);
    }
开发者ID:heyx3,项目名称:NinjaDiscountWarehouse,代码行数:26,代码来源:TutorialController.cs

示例6: Start

	void Start()
	{
        // Get all boundaries
        mTransform      = transform;
		top_Boundary    = mTransform.FindChild("top");
		bottom_Boundary = mTransform.FindChild("bottom");

        if (Hud_Top == null || Hud_Bottom == null)
        {
            Debug.LogError("Hud was not assign to boundaries!");
            return;
        }

        top_Boundary.renderer.enabled    = false;
        bottom_Boundary.renderer.enabled = false;

        transitionStart     = top_Boundary.localPosition;
        transitionStart_Hud = Hud_Top.localPosition;

        transitionEnd    = transitionStart;
        transitionEnd.y -= collider_offset;
        transitionEnd_Hud    = transitionStart_Hud;
        transitionEnd_Hud.y -= hud_offset;

        Manager_LevelDifficulty.KillObstacleEvent += KillBoundaryCollapse;
   	}
开发者ID:Kurukshetran,项目名称:Gravity,代码行数:26,代码来源:Manager_Boundaries.cs

示例7: Awake

    void Awake()
    {
        m_instance = transform.GetComponentsInChildren<MogoForwardLoadingUIManager>(true)[0];
        m_myTransform = transform;

        m_goGlobleLoadingUI = m_myTransform.FindChild("MogoGlobleLoadingUI").gameObject;

        bool isContinue = true;
        for (int i = 0; isContinue; i++)
        {
            Transform m_goGlobleLoadingUIButtonTemp = m_myTransform.FindChild(String.Concat("MogoGlobleLoadingUIButton", i));
            if (m_goGlobleLoadingUIButtonTemp)
            {
                m_goGlobleLoadingUIButtonTemp.gameObject.AddComponent<MogoGlobleLoadingUIButton>();
            }
            else
            {
                isContinue = false;
            }
        }

        m_defaultUI = GameObject.Find("MogoDefaultUI");
        m_goLoadingUICamera = m_defaultUI.transform.FindChild("DefaultUICamera").gameObject;
        m_mgl = m_goGlobleLoadingUI.AddComponent<MogoGlobleLoadingUI>();

        //Debug.LogError("MogoForwardLoadingUIManager awake!");

    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:28,代码来源:MogoForwardLoadingUIManager.cs

示例8: Start

	// Use this for initialization
	void Start () 
	{
		myTransform = GetComponent<Transform> ();
		targetTransform = myTransform.FindChild ("Target").GetComponent<Transform> ();
		target2Transform = myTransform.FindChild ("Target2").GetComponent<Transform> ();
		myRenderer = GetComponent<Renderer> ();
		lastPosition = myTransform.position;
		if (isLocalPlayer) 
		{
			myTransform.FindChild("camera4player").GetComponent<Camera>().enabled = true;// activer camera joueur local uniquement 
			myRenderer.material.color = new Color (1, 0, 0); // colorer en rouge le joueur local
			TransmitPosition ();
			TransmitRotation ();
			scoreText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("ScoreTxt").GetComponent<Text>();
			lifeText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("HealthTxt").GetComponent<Text>();
			manaText = GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("ManaTxt").GetComponent<Text>();
			weaponText =GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("WeaponTxt").GetComponent<Text>();
			staminaText =GameObject.Find ("HUD").GetComponent<Transform> ().FindChild ("StaminaTxt").GetComponent<Text>();
			//Debug.Log(GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").GetComponent<Scrollbar>());
			healthBar = GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").GetComponent<Scrollbar>();
			healthColor = GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").FindChild("Mask").FindChild("Sprite").GetComponent<Image>();
			//Debug.Log(GameObject.Find("HealthbarHUD").GetComponent<Transform>().FindChild("Healthbar").FindChild("Mask").FindChild("Sprite").GetComponent<Image>());
			manaBar =GameObject.Find("ManabarHUD").GetComponent<Transform>().FindChild("Manabar").GetComponent<Scrollbar>();
			staminaBar =GameObject.Find("StaminabarHUD").GetComponent<Transform>().FindChild("Staminabar").GetComponent<Scrollbar>();

		}


		//idTest = GetComponent<NetworkIdentity> ().netId.Value;
	}
开发者ID:La-Confrerie-des-Bisounours,项目名称:MVMA-2,代码行数:31,代码来源:Player.cs

示例9: Awake

 void Awake()
 {
     tf = transform;
     shapeRenderer = tf.FindChild("Shape").GetComponent<SpriteRenderer>();
     choideRenderer = tf.FindChild("Choice").GetComponent<SpriteRenderer>();
     UnSetChoice();
 }
开发者ID:troyhector,项目名称:SlotMachine_unity,代码行数:7,代码来源:Tile.cs

示例10: Awake

 void Awake()
 {
     innerPanel = transform.GetChild (0);
     fullname = innerPanel.FindChild ("Name").GetComponent<Text> ();
     upperText = innerPanel.FindChild ("UpperText").GetComponent<Text> ();
     lowerText = innerPanel.FindChild ("LowerText").GetComponent<Text> ();
     picture = innerPanel.FindChild ("PicturePanel").GetComponentInChildren<Image> ();
 }
开发者ID:Strathcona,项目名称:SpaceGame,代码行数:8,代码来源:FramePanel.cs

示例11: DrawCardImage

 public void DrawCardImage(Transform transform)
 {
     transform.FindChild("Name").GetComponent<Text>().text = _name;
     transform.FindChild("Description").GetComponent<Text>().text = _description;
     transform.FindChild("Cost").GetComponent<Text>().text = _cost.ToString();
     transform.FindChild("Icon").GetComponent<Image>().sprite = null;
     transform.FindChild("Image").GetComponent<Image>().sprite = _image;
 }
开发者ID:Wirdo91,项目名称:Fort-Cat,代码行数:8,代码来源:CardBase.cs

示例12: Awake

    void Awake()
    {
        m_myTransform = transform;

        m_spComboAttackBG = m_myTransform.FindChild("ComboAttackBG").GetComponentsInChildren<UISprite>(true)[0];
        m_spComboAttackHit = m_myTransform.FindChild("ComboAttackHit").GetComponentsInChildren<UISprite>(true)[0];
        m_goComboAttackNumList = m_myTransform.FindChild("ComboAttackNumList").gameObject;
        m_tsCombo = m_myTransform.GetComponentsInChildren<TweenScale>(true)[0];
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:9,代码来源:ComboAttack.cs

示例13: Awake

 void Awake()
 {
     m_myTransform  = transform;
     m_spIcon = m_myTransform.FindChild("NewChallengeUIGridBG").GetComponentsInChildren<UISprite>(true)[0];
     m_goFXList = m_myTransform.FindChild("NewChallengeUIGridFXList").gameObject;
     m_lblName = m_myTransform.FindChild("NewChallengeUIGridName").GetComponentsInChildren<UILabel>(true)[0];
     m_lblStatusText = m_myTransform.FindChild("NewChallengeUIGridText").GetComponentsInChildren<UILabel>(true)[0];
     m_spFG = m_myTransform.FindChild("NewChallengeUIGridNameFG").GetComponentsInChildren<UISprite>(true)[0];
 }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:9,代码来源:NewChallengeGrid.cs

示例14: Start

 // Use this for initialization
 void Start()
 {
     tank = GetComponent<Transform>();
     body = tank.FindChild("TankBody");
     tower = tank.FindChild("TankTower");
     pView = GetComponent<PhotonView>();
     tankUI = tank.FindChild("TankCanvas").GetComponent<Canvas>();
     tankUI.enabled = false;
 }
开发者ID:greece57,项目名称:MultiplayerTanks,代码行数:10,代码来源:TankController.cs

示例15: Start

	// Use this for initialization
	void Start () 
	{
		playerRef = transform.root.GetComponent<Controller>();
		healthPanel = transform.FindChild("HealthPanel");
		strengthPanel = transform.FindChild("StrengthPanel");
		healthBar = healthPanel.FindChild("Overlay").GetComponent<Image>();
		followBar = healthPanel.FindChild("Follow").GetComponent<Image>();
		strengthBar = strengthPanel.FindChild("Overlay").GetComponent<Image>();
	}
开发者ID:AnonymousRandomPerson,项目名称:Rangers,代码行数:10,代码来源:PlayerUI.cs


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