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


C# Canvas.GetComponentInChildren方法代码示例

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


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

示例1: Start

    // Use this for initialization
    void Start()
    {
        _highScoreCanvas = GetComponentInChildren<Canvas>();
        PlayerNameInputText = _highScoreCanvas.GetComponentInChildren<InputField>();
        if(PlayerNameInputText != null)
        {
            Text[] inputTexts = PlayerNameInputText.gameObject.GetComponentsInChildren<Text>();
            foreach(Text t in inputTexts)
            {
                if (t.name == "Placeholder") t.text = UsersData.DEFAULT_NAME;
            }
        }

        Text[] texts = _highScoreCanvas.GetComponentsInChildren<Text>();
        foreach(Text t in texts)
        {
            t.fontSize = (int)(t.fontSize * ((Screen.width) / 1236f));

            if (t.name.Contains("Player Name")) RankPlayerNameText = t;
            else if(t.name.Contains("Scores")) RankScoreText = t;
        }

        obj_localHighScore = LocalHighScore.getInstance();
        obj_localHighScore.setMaxUser(maxNumOfUsers);
        minScore = obj_localHighScore.getMinScore();

        LoadScores();
    }
开发者ID:ShinWonYoung,项目名称:HGU-SE-15,代码行数:29,代码来源:HighScoreManager.cs

示例2: Awake

 void Awake()
 {
     saved = false;
     actor = gameObject.GetComponent<Actor> ();
     dialogueCanvas = GameObject.Find ("DialougeCanvas").GetComponent<Canvas> ();
     canvasText = dialogueCanvas.GetComponentInChildren<Text> ();
     dialogueCanvas.gameObject.SetActive (false);
 }
开发者ID:WhenYouWriteStuffAndSuddenlyWildRacism,项目名称:project-lesscontra,代码行数:8,代码来源:DialogueSystem.cs

示例3: Awake

    void Awake()
    {
        #region Initialize stuff
        currentHealth = Hp;
        HealthBar = this.GetComponentInChildren<Canvas>();
        HealthBar.name = "HealthBar_" + this.gameObject.name;
        //HealthBar.transform.parent = null;
        HealthBar.transform.SetParent(null, false);
        m_hHpSlider = HealthBar.GetComponentInChildren<Slider>();
        m_hSliderRectTransform = m_hHpSlider.GetComponent<RectTransform>();
        //m_hDisassembler             = GetComponent<MeshDisassembler>();
        m_hRigidbody = GetComponent<Rigidbody>();
        m_hController = GetComponent<IControllerPlayer>() as MonoBehaviour;
        m_hProvider = GetComponent<InputProviderPCStd>();
        m_hWeapon = GetComponent<IWeapon>() as MonoBehaviour;
        m_hRenderers = new List<Renderer>(GetComponents<Renderer>());
        m_hRenderers.AddRange(GetComponentsInChildren<Renderer>());
        m_hColliders = new List<Collider>(GetComponents<Collider>());
        m_hColliders.AddRange(GetComponentsInChildren<Collider>());
        m_hBomb = GetComponent<DeathBomb>();
        m_hAudioCtrl = this.GetComponent<MadMaxCarAudio>();

        impactCoolDownActors = new LinkedList<MadMaxActor>();
        PlayableCenterOfMass = m_hRigidbody.centerOfMass;

        wheels = GetComponent<ControllerWheels>();

        //dmgImgMGR = GameManager.Instance.GetComponentInChildren<DMGImageMGR>();

        CanTakeDamage = true;
        #endregion

        if (HpBarMode == HealthBarMode.WorldSpace)
        {
            HealthBar.renderMode = RenderMode.WorldSpace;
        }
        else
        {
            HealthBar.renderMode = RenderMode.ScreenSpaceOverlay;
        }
    }
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:41,代码来源:MadMaxActor.cs

示例4: Awake

    void Awake()
    {
        directory = "/Resources/SaveGames";
        saveGames = new List<SaveGame>();
        canvas = GetComponentInChildren<Canvas>();
        image = canvas.GetComponentInChildren<Image>().sprite;
        buttonSpace = 8;

        if(!Directory.Exists(Application.dataPath + directory))
        {
            Directory.CreateDirectory(Application.dataPath + directory);
        }

        DirectoryInfo dir = new DirectoryInfo(Application.dataPath + directory);
        FileInfo[] info = dir.GetFiles("*.xml");

        foreach(FileInfo fileInfo in info)
        {
            SaveGame saveGame = new SaveGame(fileInfo.Name.Replace(".xml", ""), fileInfo.FullName, fileInfo.DirectoryName + "/" + fileInfo.Name.Replace(".xml", ""));
            saveGames.Add(saveGame);
            int ID = System.Array.IndexOf(info, fileInfo);
            CreateSaveGameButtons(saveGame, ID);
        }
    }
开发者ID:Astha666,项目名称:Time-Journey,代码行数:24,代码来源:SaveGameManager.cs

示例5: Start

    public void Start()
    {
        this.Client = GameObject.Find("Network").GetComponent<Client>();
        this.Client.MessageDisturbanceEvent += Client_MessageDisturbanceEvent;
        this.Client.MessageSystemEndOfGameEvent += Client_MessageSystemEndOfGameEvent;

        Vector3 harborPosition;
        switch (this.nameMinorIsland)
        {
            case "sous_ile_1":
                harborPosition = new Vector3(-83, 84, -3);
                break;
            case "sous_ile_2":
                harborPosition = new Vector3(130, 110, -3);
                break;
            case "sous_ile_3":
                harborPosition = new Vector3(-107, -69, -3);
                break;
            default:
                harborPosition = new Vector3(106, -71, -3);
                break;
        }
        buildingManager.createBuilding(TypeBuilding.Harbor, harborPosition);

        if (nameMinorIsland == "sous_ile_1")
        {
            Canvas startCanvasPrefab = Resources.Load<Canvas>("Prefab/StartCanvas");
            startCanvas = Instantiate(startCanvasPrefab);
            startCanvas.name = "StartCanvas";
            Color color = startCanvas.GetComponentInChildren<SpriteRenderer>().color;
            color.a = 1;
            startCanvas.GetComponentInChildren<SpriteRenderer>().color = color;
            StartCoroutine(this.startFade());
        }
    }
开发者ID:TerisseNicolas,项目名称:Archip3l,代码行数:35,代码来源:MinorIsland.cs

示例6: BlankScreen

        public BlankScreen(Color color)
        {
            GameObject o = GameObject.Find("ScreenFade");

            if (o != null)
            {
                canvas = o.GetComponent<Canvas>();
                screen = canvas.GetComponentInChildren<Image>();
            }
            else
            {
                canvas = new GameObject("ScreenFade").AddComponent<Canvas>();
                screen = new GameObject("Fader").AddComponent<Image>();
            }

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            screen.transform.SetParent(canvas.transform);

            screen.rectTransform.anchorMax = new Vector2(1, 1);
            screen.rectTransform.anchorMin = new Vector2(0, 0);
            screen.rectTransform.offsetMax = new Vector2(0, 0);
            screen.rectTransform.offsetMin = new Vector2(0, 0);

            screen.color = color;
        }
开发者ID:ofx360,项目名称:rpg-project,代码行数:25,代码来源:GameCamera.cs

示例7: Start

    void Start()
    {
        currentStep = PlayerHistoryStep.HELLCIRCLE;
        HistorySelection = GetComponent<Canvas> ();
        HistoChoiceDescription = HistorySelection.GetComponentInChildren<RectTransform> ();
        ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();

        for (int i=0; i<9; i++) {
            Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
        }
        for (int i=0; i<10; i++) {
            HistoryChoiceDisplay [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Text> () [i];
        }
        for (int i=0; i<9; i++) {
            HistoryChoiceImage [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
        }

        GetHistoryUIButtons ();

        HistorySelection.enabled = false;
    }
开发者ID:Rgallouet,项目名称:Blue-Star,代码行数:21,代码来源:HistorySelectionButtons.cs

示例8: Update

    void Update()
    {
        if (!ended)
        {
            if (GameObject.Find("sous_ile_1").GetComponent<Tuto_MinorIsland>().harborRemoved &&
                GameObject.Find("sous_ile_2").GetComponent<Tuto_MinorIsland>().harborRemoved &&
                GameObject.Find("sous_ile_3").GetComponent<Tuto_MinorIsland>().harborRemoved &&
                GameObject.Find("sous_ile_4").GetComponent<Tuto_MinorIsland>().harborRemoved)
            {
                this.ended = true;
                if (nameTuto_MinorIsland == "sous_ile_1")
                {
                    Canvas endCanvasPrefab = Resources.Load<Canvas>("Prefab/Tuto/EndCanvas");
                    endCanvas = Instantiate(endCanvasPrefab);
                    Color color = endCanvas.GetComponentInChildren<SpriteRenderer>().color;
                    color.a = 0;
                    endCanvas.GetComponentInChildren<SpriteRenderer>().color = color;
                }

            }
        }
        if(ended && this.verticalTutoCompleted && !this.startEndAnimationFlag && this.nameTuto_MinorIsland == "sous_ile_1")
        {
            StartCoroutine(this.endFade());
            this.startEndAnimationFlag = true;
        }

        /*------- open exchangeWindow after 1 sec --------*/

        /*if (this.begun)
        {
            if ((Time.time - TouchTime > 1) && (Time.time - TouchTime < 1.5))
            {
                TouchTime = 0;
                if (this.harborUpgraded && !this.exchangeResourceOpened)
                {
                    displayPopup("Vous pouvez accéder à cette fenêtre à n'importe quel moment grâce à un appui long. Fermez la fenêtre.", 5);
                    this.createExchangeWindowTuto();
                }
            }
        }*/

        if (abort)
        {
            SceneSupervisor.Instance.loadLoadingScences();
        }
    }
开发者ID:TerisseNicolas,项目名称:Archip3l,代码行数:47,代码来源:Tuto_MinorIsland.cs

示例9: Start

    void Start()
    {
        PreDefinedSelection = GetComponent<Canvas> ();

        data.Load(CSVSource);

        HistoChoiceDescription = PreDefinedSelection.GetComponentInChildren<RectTransform> ();
        ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();

        for (int i=0; i<9; i++) {
            Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
        }

        for (int i=0; i<9; i++) {
            HistoryChoiceImage [i] = PreDefinedSelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
        }

        for (int i = 0; i < 9; i++)

        GetPreDefinedUIButtons ();
        PreDefinedSelection.enabled = false;
    }
开发者ID:Rgallouet,项目名称:Blue-Star,代码行数:22,代码来源:PreDefinedSelectionButtons.cs

示例10: Start

    void Start()
    {
        menu = MenuScript.Instance;
        chat = GameObject.Find("Chat").GetComponent<Canvas>();
        text =  chat.GetComponentInChildren<Text>();
        dialogImage = chat.GetComponentInChildren<Image>();

        journalScript = GetComponent<JournalScript>();
        smallInput = GameManagerScript.SB.GetComponent<PlayerInputScript>();
        bigInput = GameManagerScript.BB.GetComponent<PlayerInputScript>();

        chat.enabled = false;
    }
开发者ID:Gotyn,项目名称:WHICH,代码行数:13,代码来源:DialogueScript.cs

示例11: openShopWindow

    /*
     * This method opens the shop window from the shopUI Prefab (set in the inspector).
     * It then sets all the visual components up, assigns them to variables and updates the shop.
     */
    private void openShopWindow()
    {
        _player.GetComponent<PlayerController>().ignoreInput = true; // While the menu is open, ignore the player's movement
        _shopUI = Object.Instantiate(shopUIPrefab) as Canvas;

        _dropdown = _shopUI.GetComponentInChildren<Dropdown>();
        // Add a listener to update the current item info when a new item is selected from the dropdown item list
        _dropdown.onValueChanged.AddListener((int i) => {
            this.updateCurrentItemInfo();
        });

        // Access the Text elements of the shop UI and make them blank for now
        foreach(Text t in _shopUI.GetComponentsInChildren<Text>()){
            if(t.name == "Quantity"){
                _quantity = t;
                _quantity.text = "";
            }
            else if(t.name == "Price"){
                _price = t;
                _price.text = "";
            }
        }

        _slider = _shopUI.GetComponentInChildren<Slider>();
        // We add a listener to the quantity slider
        // When the amount of item requested is changed, the quantity text and total price update
        _slider.onValueChanged.AddListener((float f) => {
            if(_dropdown.value != 0){
                _quantity.text = _slider.value + "";
                _price.text = "$ " +((int)_slider.value) * _prices[_dropdownIDs[_dropdown.value]]; //Total price = Quantity * price of current item
            }
        });
        _slider.gameObject.SetActive(false); // Hide the slider until we select an item from the dropdown

        Button[] buttons = _shopUI.GetComponentsInChildren<Button>();
        buttons[0].onClick.AddListener(() => { // Set the "<Back" button to close the shop
            this.closeShopWindow();
        });
        buttons[1].onClick.AddListener (() =>{ // Set the "Buy" button to attempt to purchase the chosen quantity of the chosen item
            this.buy();
        });
        updateDropdownList();
    }
开发者ID:ryanjk,项目名称:PinkPlatypus,代码行数:47,代码来源:ShopMain.cs


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