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


C# Image.GetComponent方法代码示例

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


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

示例1: setElement

	public void setElement(Image image) {
		switch (element) {
		case "Fire":
			fireCount--;
			image.GetComponent<Image> ().color = Color.red;
			drops[image.gameObject] = timeVisible;
			currentButton.GetComponentInChildren<Text> ().text = fireCount.ToString();
			break;
		case "Water":
			waterCount--;
			image.GetComponent<Image> ().color = Color.blue;
			drops[image.gameObject] = timeVisible;
			currentButton.GetComponentInChildren<Text> ().text = waterCount.ToString();
			break;
		case "Grass":
			grassCount--;
			image.GetComponent<Image> ().color = Color.green;
			drops[image.gameObject] = timeVisible;
			currentButton.GetComponentInChildren<Text> ().text = grassCount.ToString();
			break;
		default:
			print ("no element");
			break;
		}

		element = null;
	}
开发者ID:indexsky,项目名称:ManaMadnessDefense,代码行数:27,代码来源:Elements.cs

示例2: FadePanelIn

    public IEnumerator FadePanelIn(Image panelToFade)
    {
        float alpha = panelToFade.GetComponent<Image>().color.a;

        for(float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
        {
            Color newColor = panelToFade.GetComponent<Image>().color;
            newColor.a = Mathf.Lerp(alpha, .7f, t);
            panelToFade.GetComponent<Image>().color = newColor;
            yield return null;
        }
    }
开发者ID:chocobo555,项目名称:WolfWoman,代码行数:12,代码来源:Fader.cs

示例3: FadePanelOut

    public IEnumerator FadePanelOut(Image panelToFade)
    {
        float alpha = panelToFade.GetComponent<Image>().color.a;

        float t = 0;
        for (float i = 1f; i > 0f; i -= Time.deltaTime / aTime)
        {
            t += Time.deltaTime / aTime;

            Color newColor = panelToFade.GetComponent<Image>().color;
            newColor.a = Mathf.Lerp(alpha, 0, t);
            panelToFade.GetComponent<Image>().color = newColor;
            yield return null;
        }
    }
开发者ID:chocobo555,项目名称:WolfWoman,代码行数:15,代码来源:Fader.cs

示例4: Start

	void Start()
	{
		animator = transform.parent.parent.GetComponent<Animator> ();
		hitCollider = transform.parent.parent.GetComponent<Collider2D> ();
		rollTime = rollDuration;
		myAudioSource = GetComponent<AudioSource>();
		playerMovementScript = transform.parent.transform.parent.GetComponent<PlayerFighterMovement>();
		enginesFighterScript = transform.parent.transform.parent.GetComponent<EnginesFighter>();

		if(playerControlled)
		{
			dodgeCooldownImage = GameObject.Find("Dodge Cooldown Image").GetComponent<Image>();
			dodgeCooldownImageText = dodgeCooldownImage.GetComponentInChildren<Text>();
			awarenessManaFillImage = GameObject.Find("Awareness Image").GetComponent<Image>();
			awarenessMeterAudioSource = awarenessManaFillImage.GetComponent<AudioSource>();
			powerupReadyImage = GameObject.Find("Powerup Image").GetComponent<Image>();

			if(powerupMechanicEnabled)
			{
				awarenessManaFillImage.fillAmount = (float)currentAwarenessLevel/maxAwarenessLevel;
				if(currentAwarenessLevel != maxAwarenessLevel)
					powerupReadyImage.transform.localScale = Vector3.zero;
				else
				{
					powerupReadyImage.transform.localScale = Vector3.one;
					_battleEventManager.instance.playerHasOneHitKills = true;
				}
			}
			else
			{
				awarenessManaFillImage.gameObject.SetActive(false);
			}
		}

	}
开发者ID:JtheSpaceC,项目名称:Space-Game,代码行数:35,代码来源:Dodge.cs

示例5: CreateHealthBar

 void CreateHealthBar()
 {
     healthBar = Instantiate (healthBar) as Image;
     transform = healthBar.GetComponent<Transform> ();
     transform.SetParent (GameObject.FindGameObjectWithTag ("Canvas").GetComponent<Transform> ());
     transform.Translate (new Vector3 (0, 3));
     curHealthBar = healthBar.GetComponentsInChildren<Image> () [1];
 }
开发者ID:skip-thurm,项目名称:wizard-game,代码行数:8,代码来源:Health.cs

示例6: Initialize

	public void Initialize()
	{
		// Initialize references
		_canvas = GetComponent<Canvas>();
		_image = GetComponentInChildren<Image>();
		_rectTransform = _image.GetComponent<RectTransform>();

		_canvas.enabled = false;
	}
开发者ID:stijndelaruelle,项目名称:ggj2016,代码行数:9,代码来源:Icon.cs

示例7: CreateHealthBar

    void CreateHealthBar()
    {
        targetTransform = GetComponent<Transform> ();

        obj = Instantiate (healthBar) as Image;
        healthBarTransform = obj.GetComponent<Transform> ();

        healthBarTransform.SetParent (GameObject.FindGameObjectWithTag ("Canvas").GetComponent<Transform> ());
        curHealthBar = obj.GetComponentsInChildren<Image> () [1];
    }
开发者ID:tvance989,项目名称:wizard-game,代码行数:10,代码来源:Health.cs

示例8: Awake

 void Awake()
 {
     data = GameData.instance.GetBuildingData(gameObject.name);
     Debug.Log(data.ToString());
     sprite = GetComponent<Image>();
     labelText.text = data.name;
     RectTransform labelRect = label.GetComponent<RectTransform>();
     labelRect.anchoredPosition = new Vector2(0, sprite.GetComponent<RectTransform>().sizeDelta.y / 4);
     labelRect.sizeDelta = new Vector2(labelText.preferredWidth + 30, labelRect.sizeDelta.y);
 }
开发者ID:UnBiHealth,项目名称:fisiogame,代码行数:10,代码来源:Building.cs

示例9: Awake

    // Use this for initialization
    void Awake()
    {
        text = GetComponent<Text>();

        image = new GameObject().AddComponent<Image>();
        image.sprite = Resources.Load<Sprite>("Textures/square");
        image.transform.SetParent(transform);
        image.color = CursorColor;

        rt = image.GetComponent<RectTransform>();
    }
开发者ID:PeteJBB,项目名称:SupremeViolence,代码行数:12,代码来源:TextCursorEffect.cs

示例10: RandomizeImage

    private float RandomizeImage(Image img, float y)
    {
        var h = Random.Range(minHeight, maxHeight);
        var rt = img.GetComponent<RectTransform>();
        rt.anchorMin = new Vector2(0, y);
        rt.anchorMax = new Vector2(1, y + h);
        rt.offsetMin = new Vector2(0, 0);
        rt.offsetMax = new Vector2(0, 0);

        return h;
    }
开发者ID:PeteJBB,项目名称:SupremeViolence,代码行数:11,代码来源:DecruncherEffect.cs

示例11: Start

 // Use this for initialization
 void Start()
 {
     foreach(Transform t in GetComponent<RectTransform>())
     {
         if (t.name.Equals("Image"))
         {
             currentImage = t.GetComponent<Image>();
             currentImage.GetComponent<RectTransform>().sizeDelta = new Vector2(1080, 1720);
             currentImage.overrideSprite = tutorialImages[0];
         }
     }
     //GetComponent<RectTransform>().position = new Vector2(540,960);
 }
开发者ID:LudusExtremus,项目名称:Trainingspartner-Kraftwerk,代码行数:14,代码来源:TutorialHandler.cs

示例12: Awake

    void Awake()
    {
        instance = Instantiate (guiPrefab);
        imagePanel = instance.Find("Image").GetComponentInChildren<Image> ();
        imagePanel.GetComponent<Image> ().sprite = image;

        textPanel = instance.GetComponentInChildren<Text> ();
        textPanel.text = text;

        instance.SetParent (UICanvas.transform, false);
        Vector3 guiPosition = Camera.main.WorldToScreenPoint(this.transform.position);
        guiPosition.Set (guiPosition.x, guiPosition.y + 300f, guiPosition.z);
        instance.GetComponent<RectTransform>().position = guiPosition;
        hide ();
    }
开发者ID:aryan-firouzian,项目名称:OldBirds,代码行数:15,代码来源:PointOfInterest.cs

示例13: Init

 /// <summary>
 /// 初始化
 /// </summary>
 public void Init()
 {
     MyGameobject = gameObject;
     MyTransfrom = transform.GetComponent<RectTransform>();
     Go_Motion = MyTransfrom.FindChild("Motion").gameObject;
     MyTransfrom.FindChild("Motion").GetComponent<HitTextMotion>().Init(this);
     CanvasRect = FightSceneUI.Canvas;
     MyText = MyTransfrom.FindChild("Motion").FindChild("text").GetComponent<Text>();
     MyImage = MyTransfrom.FindChild("Motion").FindChild("image").GetComponent<Image>();
     RT_Image = MyImage.GetComponent<RectTransform>();
     Ani = MyTransfrom.FindChild("Motion").GetComponent<Animator>();
     ImagePosUp = new Vector2(0, 40);
     ImagePosCenter = new Vector2(0, 0);
     IsInit = true;
 }
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:18,代码来源:HitText.cs

示例14: CreateBackgroundElem

    public void CreateBackgroundElem()
    {
        background = new GameObject().AddComponent<Image>();
        background.gameObject.name = "background";
        background.transform.SetParent(transform.parent);
        background.transform.SetAsFirstSibling();

        var thisRect = GetComponent<RectTransform>();

        var rectTrans = background.GetComponent<RectTransform>();
        rectTrans.anchorMin = thisRect.anchorMin;
        rectTrans.anchorMax = thisRect.anchorMax;
        rectTrans.offsetMin = thisRect.offsetMin;
        rectTrans.offsetMax = thisRect.offsetMax;

        background.sprite = Resources.Load<Sprite>("Textures/square");
        background.color = BackgroundColor;
    }
开发者ID:PeteJBB,项目名称:SupremeViolence,代码行数:18,代码来源:CustomSelectable.cs

示例15: Start

 void Start()
 {
     myImageComponent = GetComponent<Image>(); //This could be canvasrenderer, image, etc. Gets a part of an object that you can see in inspector
     myImageComponent.GetComponent<Image>().enabled = false; //Make centre image invisible until a card is scanned
 }
开发者ID:Rtgosling,项目名称:LookingGlass,代码行数:5,代码来源:CardPop.cs


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