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


C# RectTransform.GetComponent方法代码示例

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


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

示例1: FadeInPanel

    public RectTransform FadingOutPanel; //Reference to panel that is currently fading out

    #endregion Fields

    #region Methods

    /// <summary>
    /// Fade in panel
    /// </summary>
    /// <param name="panel">Panel to fade in</param>
    /// <returns></returns>
    public IEnumerator FadeInPanel(RectTransform panel)
    {
        FadingInPanel = panel;
        FadingInPanel.gameObject.SetActive(true);

        while(panel.GetComponent<CanvasGroup>().alpha < 1)
        {
            panel.GetComponent<CanvasGroup>().alpha += Time.deltaTime / FadeTime;

            yield return null;
        }

        ActivePanel = panel;
        FadingInPanel = null;
    }
开发者ID:Syldarion,项目名称:DJD-JP,代码行数:26,代码来源:MainMenuPanelController.cs

示例2: FadeOutPanel

    /// <summary>
    /// Fade out panel
    /// </summary>
    /// <param name="panel">Panel to fade out</param>
    /// <returns></returns>
    public IEnumerator FadeOutPanel(RectTransform panel)
    {
        FadingOutPanel = panel;
        ActivePanel = null;

        while (panel.GetComponent<CanvasGroup>().alpha > 0)
        {
            panel.GetComponent<CanvasGroup>().alpha -= Time.deltaTime / FadeTime;

            yield return null;
        }

        FadingOutPanel.gameObject.SetActive(false);
        FadingOutPanel = null;
    }
开发者ID:Syldarion,项目名称:DJD-JP,代码行数:20,代码来源:MainMenuPanelController.cs

示例3: Initialize

 public override void Initialize()
 {
     battleSelection = transform.root.GetComponent<BattleSelection> ();
     Canvas canvas = transform.FindChild ("BattleCanvas").GetComponent<Canvas>();
     foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){
         g.SetActive(false); //set all other canvases inactive to be sure
     }
     canvas.gameObject.SetActive (true); //activate the canvas we want
     if (!initialized) {
         if (canvas != null) { //is this nessisary? probs not because I think that setactive call above will throw an exception
             leftPanel = canvas.transform.FindChild ("Left Panel").GetComponent<RectTransform> ();
             mothershipLeftPanel = canvas.transform.FindChild ("Mothership Left Panel").GetComponent<RectTransform> ();
             mothershipPanel = mothershipLeftPanel.GetComponent<BattleMothershipPanel> ();
             infoPanel = leftPanel.GetComponent<BattleInfoPanel> ();
             infoPanel.Initialize ();
             mothershipPanel.Initialize ();
             timer = GetComponent<Timer> ();
             jumpbutton = GameObject.Find ("BattleCanvas/Top Panel/JumpButton");
             jumpbutton.SetActive (false);
             initialized = true;
         } else {
             Debug.Log ("Null canvas for Battle?");
         }
     }
 }
开发者ID:Strathcona,项目名称:SpaceGame,代码行数:25,代码来源:BattleGooey.cs

示例4: SwitchTo

    public void SwitchTo(RectTransform new_panel)
    {
        if (ActivePanel)
        {
            if (ActivePanel == new_panel)
                return;

            if (ActivePanel.GetComponent<CanvasGroup>())
                PanelUtilities.DeactivatePanel(ActivePanel.GetComponent<CanvasGroup>());
        }

        ActivePanel = new_panel;

        if (ActivePanel.GetComponent<CanvasGroup>())
            PanelUtilities.ActivatePanel(ActivePanel.GetComponent<CanvasGroup>());
    }
开发者ID:Syldarion,项目名称:DJD-JP,代码行数:16,代码来源:PlayerInfoPanelController.cs

示例5: Start

    // Use this for initialization
    void Start () {
        penX.onValueChange.AddListener(ChangePenX);
        penY.onValueChange.AddListener(ChangePenY);
        brushX.onValueChange.AddListener(ChangeBrushX);
        brushY.onValueChange.AddListener(ChangeBrushY);
        bSize.onValueChange.AddListener(ChangeBSize);

        penX.text = PlayerPrefs.GetInt("penOffsetX", 0).ToString();
        penY.text = PlayerPrefs.GetInt("penOffsetY", 0).ToString();
        brushX.text = PlayerPrefs.GetInt("brushOffsetX", 0).ToString();
        brushY.text = PlayerPrefs.GetInt("brushOffsetY", 0).ToString();
        bSize.text = PlayerPrefs.GetInt("bSize", 10).ToString();

        var detector = DrawUtility.CreateDetector(prefab);

        detector.OnStartPaint += new PaintingDetector2D.DelegatePaint(OnStartPaint);
        detector.OnPaintMovement += new PaintingDetector2D.DelegatePaint(OnPaintMovement);
        detector.OnPaintEnd += new PaintingDetector2D.DelegatePaint(OnPaintEnd);


        drawRect = DrawUtility.CreateRectTransform(prefab, new Vector2(Screen.width, Screen.height));
        drawImage = drawRect.GetComponent<RawImage>();
        paintTexture = DrawUtility.CreateCanvas(Screen.width, Screen.height);
        drawImage.texture = paintTexture;

        btn.onClick.AddListener(Click);
    }
开发者ID:Blizzardx,项目名称:ClientFrameWork,代码行数:28,代码来源:DrawSetting.cs

示例6: Start

 void Start()
 {
     mRectTransform = this.transform as RectTransform;
     _btn = mRectTransform.GetComponent<Button>();
     _mask = mRectTransform.Find("mask").GetComponent<Image>();
     _mask.transform.localPosition = Vector3.zero;
     _mask.enabled = false;
 }
开发者ID:zhaoyabo,项目名称:GameBase,代码行数:8,代码来源:UIBtnCD.cs

示例7: Awake

 void Awake()
 {
     panelTournament = transform.FindChild("PanelTournament") as RectTransform;
     panelNormal = transform.FindChild("PanelNormal") as RectTransform;
     panelPlayerList = transform.FindChild("PanelPlayerList") as RectTransform;
     panelChatBox = transform.FindChild("PanelChatBox") as RectTransform;
     chatBox = panelChatBox.GetComponent<ChatBoxControl>();
 }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:8,代码来源:SideBar.cs

示例8: getView

 public override RectTransform getView(RectTransform currentView, int position)
 {
     if (currentView == null) {
         currentView = Instantiate(prefab);
     }
     Text text = currentView.GetComponent<Text>();
     text.text = textList[position] + " pos=" + position;
     return currentView;
 }
开发者ID:kirinchen,项目名称:unity-adapter-listview,代码行数:9,代码来源:ExampleAdapter.cs

示例9: MoveScene

    void MoveScene(RectTransform obj,int scnarioNumber)
    {
        Button button = obj.GetComponent<Button> ();

        button.onClick.AddListener (() => {
            NovelSingleton.StatusManager.callJoker("wide/scene"+ scnarioNumber,"");

        });
    }
开发者ID:yota2013,项目名称:ApplicationProject,代码行数:9,代码来源:CreateBottom.cs

示例10: Start

 void Start()
 {
     internalRect = transform.FindChild ("Internal").GetComponent<RectTransform>();
     externalRect = transform.FindChild ("External").GetComponent<RectTransform>();
     internalButtons = internalRect.GetComponent<ButtonOrganizer> ();
     externalButtons = externalRect.GetComponent<ButtonOrganizer> ();
     attachmentPanel = PrefabLoader.GetGUIObject ("AttachmentPanel");
     userInput = transform.root.GetComponent<ShipEditorUserInput> ();
 }
开发者ID:Strathcona,项目名称:SpaceGame,代码行数:9,代码来源:HardpointDisplay.cs

示例11: Start

	protected override void Start ()
    {
		PlaceHolder = transform.GetChild(0) as RectTransform;
        PlaceHolder.GetComponent<Image>().sprite = imageButteon.sprite;
		rectTransf = transform as RectTransform;
		menu = rectTransf.parent.GetComponent<CirculareMenu>();

		isStarted = true;
    }
开发者ID:Cataklyste,项目名称:Ethno,代码行数:9,代码来源:MenuButton.cs

示例12: Start

    public void Start() {
        // get components
        canvas = GameObject.Find("StatUI").GetComponent<RectTransform>();
        game = canvas.GetComponent<Game>();
        model = transform.Find("Model").transform;
        player = GameObject.Find("Player").transform;
        nav = GetComponent<NavMeshAgent>();
        nav.speed = Random.Range(2.0f, 5.5f);

        // build healthbar
        GameObject backGO = new GameObject("healthbarback");
        backGO.transform.parent = canvas.Find("HealthBars").transform;
        GameObject healthGO = new GameObject("healthbar");
        healthGO.transform.parent = canvas.Find("HealthBars").transform;

        healthBar = healthGO.AddComponent<Image>();
        backBar = backGO.AddComponent<Image>();

        healthBar.color = Color.red;
        backBar.color = new Color(0.2f, 0.0f, 0.0f);

        healthBar.rectTransform.sizeDelta = new Vector2(100, 5);
        backBar.rectTransform.sizeDelta = new Vector2(100, 5);

        backBar.rectTransform.pivot = Vector2.zero;
        healthBar.rectTransform.pivot = Vector2.zero;

        switch (type) {
            case EnemyType.ORC:
                hp = 2.0f + game.level;
                damage = 2.0f + game.level;
                break;
            case EnemyType.SKELETON:
                hp = 0.5f + game.level / 3.0f;
                damage = 1.0f + (game.level) / 3.0f;
                break;
            case EnemyType.MAGE:
                hp = 1.0f + game.level / 3.0f;
                damage = 2.5f + game.level / 2.0f;
                break;
            case EnemyType.RANGER:
                hp = 1.0f + game.level / 2.0f;
                damage = 1.0f + game.level / 2.0f;
                break;
            case EnemyType.CROSSBOW:
                hp = 1.0f + game.level / 1.5f;
                damage = 1.0f + game.level / 2.0f;
                break;
            default:
                hp = 1.0f + game.level / 2.0f;
                damage = 1.0f + game.level / 2.0f;
                break;
        }

        maxhp = hp;
    }
开发者ID:buckslice,项目名称:statlord,代码行数:56,代码来源:EnemyBasicScript.cs

示例13: Awake

        void Awake()
        {
            On("OnMainCameraChange");

            _healthContainer = GetComponentInChildren<Image>().gameObject;
            _healthContainer.GetComponentInParent<Canvas>().worldCamera = Camera.main;
            _rectTransform = _healthContainer.GetComponent<RectTransform>();
            _healthBar = _healthContainer.transform.FindChild("HealthBar").GetComponent<RectTransform>();
            _image = _healthBar.GetComponent<Image>();
            _krHealth = transform.GetComponentInParent<KRHealth>();
        }
开发者ID:HyroVitalyProtago,项目名称:KingdomsRebellion,代码行数:11,代码来源:HealthBar.cs

示例14: Summon

 //summon activates whenever a card is played. All spells (at least for now) target a specific tile.
 public override Transform Summon(RectTransform location, Transform hand)
 {
     if (location.GetComponent<Tile_Component>().unit != null)
         location.GetComponentInChildren<BaseUnit_Component>().TakeDamage(5);
     else
     {
         hand.GetComponent<ResourceManager>().AddResources(cost);
         hand.GetComponent<Hand_Component>().AddCard(0003);
     }
     return transform;
 }
开发者ID:GOTFCodingTeam,项目名称:GOTF2.0,代码行数:12,代码来源:BaseSpell_Component.cs

示例15: Summon

    //summons a creature
    public override Transform Summon(RectTransform tile, Transform hand)
    {
        Transform thisGuy = Instantiate(transform);
        tile.GetComponent<Tile_Component>().unit = thisGuy.GetComponent<RectTransform>();
        thisGuy.transform.SetParent(tile, false);

        health = maxHealth;
        attack = baseAttack;
        countdown = baseCountdown;
        return transform;
    }
开发者ID:GOTFCodingTeam,项目名称:GOTF2.0,代码行数:12,代码来源:BaseUnit_Component.cs


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