本文整理汇总了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;
}
示例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> ();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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!");
}
示例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;
}
示例9: Awake
void Awake()
{
tf = transform;
shapeRenderer = tf.FindChild("Shape").GetComponent<SpriteRenderer>();
choideRenderer = tf.FindChild("Choice").GetComponent<SpriteRenderer>();
UnSetChoice();
}
示例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> ();
}
示例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;
}
示例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];
}
示例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];
}
示例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;
}
示例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>();
}