本文整理汇总了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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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];
}
示例6: Initialize
public void Initialize()
{
// Initialize references
_canvas = GetComponent<Canvas>();
_image = GetComponentInChildren<Image>();
_rectTransform = _image.GetComponent<RectTransform>();
_canvas.enabled = false;
}
示例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];
}
示例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);
}
示例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>();
}
示例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;
}
示例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);
}
示例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 ();
}
示例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;
}
示例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;
}
示例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
}