Answers for "Gameobject.Find in unityC#"

C#
12

how to find gameobjects in unity

using UnityEngine;
using System.Collections;
// This returns the GameObject named Hand in one of the Scenes.
public class ExampleClass : MonoBehaviour
{
    public GameObject hand;    
    
    void Example()
    {
        // This returns the GameObject named Hand.
        hand = GameObject.Find("Hand");        
      
        // This returns the GameObject named Hand.
        // Hand must not have a parent in the Hierarchy view.
        hand = GameObject.Find("/Hand");     
      
        // This returns the GameObject named Hand,
        // which is a child of Arm > Monster.
        // Monster must not have a parent in the Hierarchy view.
        hand = GameObject.Find("/Monster/Arm/Hand");
        
        // This returns the GameObject named Hand,
        // which is a child of Arm > Monster.
        hand = GameObject.Find("Monster/Arm/Hand");
    }
}
Posted by: Guest on March-09-2020
3

unity find gameobject

ExampleObject = GameObject.Find("Hand");
Posted by: Guest on October-05-2020
3

unity gameobject.find

GameObject obj = GameObject.Find("/Parent/Child/ChildOfChild");
Posted by: Guest on March-25-2020
0

Gameobject.Find in unityC#

GameObject sphere = Gameobject.Find("Player");
// above code will search whole scene for the gameobject named "Player"
//
GameObject sphere = Gameobject.Find("/Player"); 
//above code will search the gameobject named "Player" but this gameobject cannot be a child

GameObject sphere = Gameobject.Find("/player/gun");
//above code will search the gun gameobject which must be the child of Player 
// and player must not be the child of any other.
Posted by: Guest on August-28-2021

C# Answers by Framework

Browse Popular Code Answers by Language