本文整理汇总了C#中SpriteRenderer.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteRenderer.GetComponent方法的具体用法?C# SpriteRenderer.GetComponent怎么用?C# SpriteRenderer.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteRenderer
的用法示例。
在下文中一共展示了SpriteRenderer.GetComponent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
_spriteRenderer = transform.GetComponentInChildren<SpriteRenderer>();
_spriteTransform = _spriteRenderer.GetComponent<Transform>();
_xSpeedRange = _defaultXSpeedRange;
_lateJumpTimer = _lateJumpTime;
_inputDevice = InputManager.ActiveDevice;
}
示例2: Start
// Use this for initialization
void Start () {
obj = GetComponent<DragableObject>();
fader = GetComponent<AudioFader>();
obj.OnDragStart += OnDragStart;
obj.OnDragStop += OnDragStop;
glowObj = new GameObject ("glow");
glowObj.transform.parent = this.transform;
glow = glowObj.AddComponent<SpriteRenderer> ();
glow.sprite = GetComponent<SpriteRenderer> ().sprite;
glow.GetComponent<Renderer>().enabled = false;
}
示例3: Start
void Start()
{
PlayerInformation.player_information.players.Add(this);
if (RespawnOnTimeScript.Respawner!=null)
{
RespawnOnTimeScript.Respawner.playerJoined();
}
// Spawn an aimer for this player
aimer = ((GameObject) Instantiate(Resources.Load("Aimer") as GameObject, this.transform.position, Quaternion.identity)).GetComponent<SpriteRenderer>();
aimer.GetComponent<FollowObject>().object_to_follow = this.transform;
aimer.enabled = false;
}
示例4: IsStaticObstacle
/// <summary>
/// Test if this is an unmovable obstacle like furniture or an appliance.
/// True if this is not a map tile, it has a box collider, and it doesn't have a RigidBody2D.
/// </summary>
private bool IsStaticObstacle(SpriteRenderer sprite)
{
if (sprite.sortingLayerName == "Map")
return false;
if (sprite.GetComponent<BoxCollider2D>() == null)
return false;
return sprite.GetComponent<Rigidbody2D>() == null;
}
示例5: Start
// Use this for initialization
void Start () {
bullet = this.gameObject;
pointValue = GetComponentInChildren<SpriteRenderer>();
pointValue.GetComponent<Renderer>().enabled = true;
}