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


C# GameObject.GetComponentInChildren方法代码示例

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


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

示例1: Awake

 private void Awake()
 {
     titleControls = GameObject.Find ("Canvas");
     btnStart = titleControls.GetComponentInChildren<Button> ();
     btnStart.onClick.AddListener (() => btnOnclick ());
     inputField = titleControls.GetComponentInChildren<InputField> ();
 }
开发者ID:mduffyg13,项目名称:Honours-Project,代码行数:7,代码来源:TitleContols.cs

示例2: SetMaster

    public void SetMaster(GameObject mas)
    {
        master = mas;
        healthGUI = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/healthObj"));
        Image health = healthGUI.GetComponentInChildren<Image>();
        Text healthtext = healthGUI.GetComponentInChildren<Text>();
        if (gameObject.transform.position.x < 0)
        {
            health.transform.localPosition = new Vector3(-40, (Screen.height / Screen.dpi) + 80, gameObject.transform.localPosition.z);
            healthtext.transform.localPosition = new Vector3(-25, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);
        }
        else
        {
            health.transform.localPosition = new Vector3(45, (Screen.height / Screen.dpi) + 80, gameObject.transform.localPosition.z);
            healthtext.transform.localPosition = new Vector3(66, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);
        }

        //health.transform.localPosition = new Vector3(gameObject.transform.localPosition.x * 13 + 11f, (Screen.height/Screen.dpi) +80, gameObject.transform.localPosition.z);
        //healthtext.transform.localPosition = new Vector3(gameObject.transform.localPosition.x *12 + 14, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);

        healthtxt = healthtext;
        healthbar = health;

        //if the forgottone
        if(gameObject.name== "Forgotten(Clone)0")
        {
            spinner1 = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/Forgottonspinner1"));
            spinner2 = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/ForgottonSpinner2"));
            spinner1.transform.localScale = new Vector3 (1.4f,1.3f,1);
            spinner2.transform.localScale = new Vector3 (1.4f,1.3f,1);
        }
    }
开发者ID:leeh14,项目名称:Vocabulary,代码行数:32,代码来源:GenericEnemy.cs

示例3: Start

    // Use this for initialization
    void Start()
    {
        if (GetComponent<Identity>().unitType.isBuilding())
        {
            //GetComponent<Health>().setHealth(50);
            //GetComponent<Health>().setMaxHealth(50);
            //GetComponent<Health>().setAuxHealth(50);
            auxMaxHealth = GetComponent<BuildingConstruction>().timer;
            maxHealth = MapValues(auxMaxHealth, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth());
            curHealth = MapValues(auxMaxHealth - GetComponent<BuildingConstruction>().timer, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth());
        }
        else
        {
            maxHealth = GetComponent<Health>().getMaxHealth();
            curHealth = GetComponent<Health>().getHealth();
        }

        g = Instantiate(prefab);
        g.transform.SetParent(GameController.Instance.healthBarsParent.transform);

        g.transform.GetChild(0).transform.position = Camera.main.WorldToScreenPoint(GetComponentInChildren<auxHealth>().gameObject.transform.position);
        g1 = g.GetComponentInChildren<auxHealth>().gameObject;

        visualHealth = g.GetComponentInChildren<auxHealth>().i;

        unitLOSEntity = gameObject.GetComponent<LOSEntity>();
    }
开发者ID:jgirald,项目名称:ES2015F,代码行数:28,代码来源:healthbar.cs

示例4: OnBeginDrag

    public void OnBeginDrag(PointerEventData eventData)
    {
        newParent = this.transform.parent;
        oldParent = this.transform.parent;
        this.transform.SetParent (this.transform.parent.parent.parent.parent.parent);
        Debug.Log ("OLD PARENT IS: " + oldParent);

        GetComponent<CanvasGroup>().blocksRaycasts = false;

        UI_Container = GameObject.FindGameObjectWithTag ("UI Container");

        //YAY GLOW
        if (oldParent.gameObject.transform.name.ToString () == "Scrollable List") {
            for (int i = 0; i < UI_Container.GetComponentInChildren<SquadSelectionScript>().MemberList.Length; i++) {
                Color glowColour = Color.Lerp (oldValue, newValue, Mathf.PingPong (Time.time, 8));
                UI_Container.GetComponentInChildren<SquadSelectionScript>().MemberList[i].GetComponent<Image>().color = glowColour;
            }
        }

        //YAY WEAPONS GLOW
        if (oldParent.gameObject.transform.name.ToString () == "Scrollable Weapons List") {
            for (int i = 0; i < UI_Container.GetComponentInChildren<SquadSelectionScript>().WeaponList.Length; i++) {
                Color glowColour = Color.Lerp (oldValue, newValue, Mathf.PingPong (Time.time, 8));
                UI_Container.GetComponentInChildren<SquadSelectionScript>().WeaponList[i].GetComponent<Image>().color = glowColour;
            }
        }
    }
开发者ID:NeonPandaSp,项目名称:ValenceGame,代码行数:27,代码来源:SquadSelection_Draggable.cs

示例5: Selected

	public void Selected(GameObject card) {
		card.transform.SetSiblingIndex (9);
        card.GetComponent<RectTransform>().sizeDelta = new Vector2(m_CardWidth * 0.9f, m_CardHeight * 0.9f);
        m_Servant = card.tag;
        if (card.GetComponentInChildren<Text>())
        {
            m_IntroText.GetComponent<Text>().text = card.GetComponentInChildren<Text>().text;
        }
        int i = 1;
        bool bigger = false;
		foreach (var item in m_Cards) {
            if (card == item)
            {
                bigger = true;
                i = 6;
            }
            else
            {
                if (bigger)
                    item.transform.SetSiblingIndex(i--);
                else
                    item.transform.SetSiblingIndex(i++);
                item.GetComponent<RectTransform>().sizeDelta = new Vector2(m_CardWidth * 0.8f, m_CardHeight * 0.8f);
            }
        }
	}
开发者ID:shana0440,项目名称:Fate-Wargames-Unity,代码行数:26,代码来源:SelectServant.cs

示例6: Swap

    public void Swap(GameObject from, GameObject to)
    {
        Transform thisposition = from.transform;
        Vector2 temp_position = thisposition.position;
        GameObject temp_parent = thisposition.parent.gameObject;

        Transform targetposition = to.transform;

        from.transform.SetParent(targetposition.parent,false);
        from.transform.position = targetposition.position;

        to.transform.SetParent(temp_parent.transform,false);
        to.transform.position = temp_position;

        if(from.transform.parent.name.Contains("Substitution")){
            from.GetComponentInChildren<PlayerDragScript>().enabled = false;
        }
        else{
            from.GetComponentInChildren<PlayerDragScript>().enabled = true;
        }
        if(to.transform.parent.name.Contains("Substitution")){
            to.GetComponentInChildren<PlayerDragScript>().enabled = false;
        }
        else{
            to.GetComponentInChildren<PlayerDragScript>().enabled = true;
        }

        from.GetComponent<PlayerAttribute>().updateNameView();
        to.GetComponent<PlayerAttribute>().updateNameView();
    }
开发者ID:elianalien,项目名称:Labbola,代码行数:30,代码来源:SwapperScript.cs

示例7: SpawnMyPlayer

 private void SpawnMyPlayer()
 {
     myPlayer = PhotonNetwork.Instantiate("Character", Vector3.zero, Quaternion.identity, 0);
     myPlayer.GetComponentInChildren<PlayerMovement>().enabled = true;
     myPlayer.GetComponentInChildren<CameraScript>().enabled = true;
     myPlayer.GetComponentInChildren<Camera>().enabled = true;
 }
开发者ID:TheCodeTinkerer,项目名称:ProjectThunder,代码行数:7,代码来源:NetworkScript.cs

示例8: DisplaySettingsFile

    public void DisplaySettingsFile(GameObject clickedButton)
    {
        // we need to clear out the children in the list before we generate new ones
        for (int i = 0; i < fieldsList.transform.childCount; i ++)
        {
            fieldsList.transform.GetChild(i).gameObject.SetActive(false);
            Debug.Log("destroying: " + fieldsList.transform.GetChild(i).name);
            Destroy(fieldsList.transform.GetChild(i).gameObject);

        }

        string file = settingsFileFolderPath + "/" + clickedButton.GetComponentInChildren<Text> ().text;

        string tmpFile = clickedButton.GetComponentInChildren<Text> ().text.Substring(0, clickedButton.GetComponentInChildren<Text> ().text.Length - 5);
        Type fileType = System.Type.GetType(tmpFile);
        activeSettingsFileType = fileType;

        WidgetSettings displayedFile = XmlIO.Load (file, fileType) as WidgetSettings;

        object[] displayedValues = displayedFile.GetValues ();

        FieldInfo[] fieldsArray = fileType.GetFields ();

        for (int i = 0; i < fieldsArray.Length; i++)
        {
            GameObject fieldUI = Instantiate (Resources.Load ("WidgetSettings/" + fieldsArray [i].FieldType.Name + "_UI")) as GameObject;
            fieldUI.transform.SetParent (fieldsList.transform);
            fieldUI.transform.FindChild("Title").GetComponent<Text>().text = fieldsArray[i].Name;
            fieldUI.GetComponent<FieldUIs>().SetFieldValue(displayedValues[i]);

        }
    }
开发者ID:ChristopherConnock,项目名称:Unity-Design-Review-System,代码行数:32,代码来源:WidgetSettingsManager.cs

示例9: OnParticleCollision

    void OnParticleCollision(GameObject other)
    {
        print("burn!!!!");
		if (other.CompareTag("Torch"))
		{
			ParticleSystem fire = other.GetComponentInChildren<ParticleSystem>();
			fire.Play();
		}
		if (other.CompareTag("Rubble"))
		{
			Debug.Log("boom");
            Rigidbody[] pieces = other.gameObject.GetComponentsInChildren<Rigidbody>();
            foreach (Rigidbody piece in pieces)
            {
                piece.isKinematic = false;
                piece.AddExplosionForce(500, other.gameObject.transform.position, 5);
            }
            BoxCollider goocollider = other.GetComponent<BoxCollider>();
            goocollider.enabled = false;
            ParticleSystem bakahatsu = other.GetComponentInChildren<ParticleSystem>();
            bakahatsu.Play();
            GameObject goo = other.transform.FindChild("Goo").gameObject;
            Destroy(goo);

		}
    }
开发者ID:Darylcxz,项目名称:ANIMA-FYP,代码行数:26,代码来源:HitbyExplosion.cs

示例10: ClickedUser

    //Called by CreateNewUser
    public void ClickedUser(GameObject userObject)
    {
        //Changes userName in SaveLoad class to the text in the first Username slot
        saveLoad.userName = userObject.GetComponentInChildren<Text>().text;
        //Deletes and then saves the Users after deltetion
        saveLoad.Delete();
        foreach(User user in createUser.listOfTypeUSERS)
        {

            if(userObject.GetComponentInChildren<Text>().text == user.getPlayerName())
            {
                Debug.Log("Deleting "+userObject.GetComponentInChildren<Text>().text);
                index = createUser.listOfUsers.IndexOf(userObject);
                createUser.listOfUsers.Remove(userObject);
                createUser.listOfTypeUSERS.Remove(user);
                Destroy (userObject);
                if(createUser.usernameNumb != 0)
                    createUser.usernameNumb--;
                else
                    createUser.usernameNumb = 4;
                createUser.userNumbTracker--;
                break;
            }

        }
        DeletionOver();
    }
开发者ID:WaterKH,项目名称:FrankensteinVendetta,代码行数:28,代码来源:DeleteUser.cs

示例11: HandleCustomProperties

    /// <summary>
    /// In the Tiled layer add a custom property called 'physicsMaterial2D' to be used in the handler
    /// The value of the property must be a valid PhysicsMaterial2D located in the Assets/Materials/PhysicsMaterial/
    /// </summary>
    public void HandleCustomProperties(GameObject gameObject,
        IDictionary<string, string> props)
    {
        //Se não existir o custom property já saimos
        if (!props.ContainsKey("physicsMaterial2D"))
        {
            return;
        }

        string materialName = props["physicsMaterial2D"] + ".physicsMaterial2D";
        string materialPath = "Assets/Materials/PhysicsMaterial/" + materialName;


        // Verificamos se o material existe, se não existir disparamos o erro e retornamos
        PhysicsMaterial2D material = AssetDatabase.LoadAssetAtPath(materialPath, typeof(PhysicsMaterial2D)) as PhysicsMaterial2D;
        if (material == null)
        {
            Debug.LogError(String.Format("Could not find material: {0}", materialName));
            return;
        }
        
        //O tiled2unity sempre exporta o collider como PolygonCollider, se mudar temos que refazer essa parte
        if (gameObject.GetComponentInChildren<PolygonCollider2D>() != null)
        {
            gameObject.GetComponentInChildren<PolygonCollider2D>().sharedMaterial = material;
        }

        
    }
开发者ID:DylanRenan,项目名称:MuvucaGame01,代码行数:33,代码来源:PhysicsMaterialImporter.cs

示例12: PopulateMap

	private void PopulateMap(GameObject mapObject)
	{
		int levelIndex = Random.Range(0, MainMenuManager.Levels.Count);
		MainMenuManager.LevelPackage level = MainMenuManager.Levels[levelIndex];
		mapObject.GetComponentInChildren<Image>().sprite = level.Thumbnail;
		mapObject.GetComponentInChildren<Text>().text = level.Name;
		m_ShownMap.Add(new ExposedMap() { Name = level.Name, GameObject = mapObject });
	}
开发者ID:GoupilRobin,项目名称:GGJ_HackSpam,代码行数:8,代码来源:MenuSelectMaps.cs

示例13: selectMonth

	public void selectMonth(GameObject opcion){
		btnMonth.GetComponentInChildren<Text> ().text = opcion.GetComponentInChildren<Text> ().text;
		Debug.Log (opcion.GetComponentInChildren<Text> ().text);

		GMS.userData.format_month (opcion.GetComponentInChildren<Text> ().text);

		DDMonth.SetActive (false);
	}
开发者ID:georgex1,项目名称:bp-unity-nuevo-proyecto,代码行数:8,代码来源:fechaNacimiento.cs

示例14: CTTestInputDisplay

 public CTTestInputDisplay(GameObject attchedGameObject)
 {
     gameObject = attchedGameObject;
     line = gameObject.GetComponentInChildren<LineRenderer>();
     text = gameObject.GetComponentInChildren<GUIText>();
     _trailVerts = new List<Vector3>();
     GameMessenger.Reg("newTestInputRecording", this, Message_newTestInputRecording);
     GameMessenger.Reg("touch", this, Message_touch);
 }
开发者ID:bcatcho,项目名称:rtsControl,代码行数:9,代码来源:CTTestInputDisplay.cs

示例15: Start

 void Start()
 {
     manaBar = GameObject.FindGameObjectWithTag("ManaBar");
     spellBar = GameObject.FindGameObjectWithTag("SpellBar");
     deathScreen = GameObject.FindGameObjectWithTag("DeathScreen");
     generator = GameObject.FindGameObjectWithTag("Generator").GetComponent<GenerateScript>();
     manaBar.GetComponentInChildren<Image>().fillMethod = Image.FillMethod.Radial360;
     manaBar.GetComponentInChildren<Image>().type = Image.Type.Filled;
 }
开发者ID:Wryxo,项目名称:FromLight,代码行数:9,代码来源:UIPlayerScript.cs


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