本文整理汇总了C#中UnityEngine.SpriteRenderer类的典型用法代码示例。如果您正苦于以下问题:C# SpriteRenderer类的具体用法?C# SpriteRenderer怎么用?C# SpriteRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpriteRenderer类属于UnityEngine命名空间,在下文中一共展示了SpriteRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowScore
private void ShowScore()
{
GameObject animatedObject = GetObjectByScore(MemoryGame.Current.ScoreChanged);
if (animatedObject != null)
{
if (lastScore != null)
{
lastScore.SetActive(false);
}
lastRenderer = null;
lastRenderer = animatedObject.GetComponent<SpriteRenderer>();
if (lastRenderer != null)
{
var color = lastRenderer.color;
color.a = 1;
lastRenderer.color = color;
}
var scale = transform.localScale;
scale.x = 0;
scale.y = 0;
transform.localScale = scale;
lastScore = animatedObject;
animatedObject.SetActive(true);
state = 0;
progress = 0;
showScore = true;
}
}
示例2: Start
//private Animator animator;
//Create the angel gameObject
public void Start()
{
//animator = GetComponent<Animator>();
moveController = GetComponent<EnemyMoveController>();
health = GetComponent<Health>();
player = FindObjectOfType<Player>();
sprRend = GetComponent<SpriteRenderer>();
boxColl = GetComponent<BoxCollider2D>();
distance = new Vector2(0, 0);
isAgro = false;
isFaking = stageThree = stageFour = false;
rnd = new System.Random(Guid.NewGuid().GetHashCode());
t = 3 + rnd.Next(0, 3000) / 1000f;
fake_CD = 0;
invis_CD = 0;
running = 0;
radius = 1;
i = 0;
attack_CD = 1;
}
示例3: Awake
// Use this for initialization
void Awake () {
// Fill the components
audioSource = this.GetComponent<AudioSource> ();
collider = this.GetComponent<BoxCollider2D> ();
sprite = this.GetComponent<SpriteRenderer> ();
if (mouthManager != null) {
mouthManager.AudioSource = audioSource;
}
// Subscribe to talkset events
onTalkSet = new TalkEventManager.TalkEvent(OnTalkSet);
onTalkStop = new TalkEventManager.TalkEvent (OnTalkStop);
TalkEventManager.TalkSet += onTalkSet;
TalkEventManager.TalkStop += onTalkStop;
// Fill the list of played audioclips
audioClipsPlayed = new List<bool> ();
foreach(AudioClip clip in audioClips) {
audioClipsPlayed.Add (false);
}
if (newMessageUiPrefab && !newMessageUi) {
// Adds the UI part
newMessageUi = Instantiate (newMessageUiPrefab);
newMessageUi.transform.SetParent (this.transform);
IsNew = false;
// Try to position it according to sprite bounds
if (sprite)
newMessageUi.transform.position = new Vector3 (sprite.bounds.center.x + sprite.bounds.size.x / 2, sprite.bounds.center.y + sprite.bounds.size.y / 2, sprite.bounds.center.z);
}
}
示例4: init
public override void init(Dictionary<string,string> param){
this.param = param;
GameObject g = Resources.Load(GameSetting.PATH_PREFAB + "Image") as GameObject;
this.rootObject = (GameObject)Instantiate(g,new Vector3(0,0f,-3.2f),Quaternion.identity);
this.rootObject.name = this.name;
//サイズを指定できる
this.spriteFore = this.rootObject.transform.FindChild("fore").gameObject;
this.spriteBack = this.rootObject.transform.FindChild("back").gameObject;
this.spriteRenderFore = this.spriteFore.GetComponent<SpriteRenderer> ();
this.spriteRenderBack = this.spriteBack.GetComponent<SpriteRenderer> ();
//Layerの設定
this.spriteRenderFore.sortingLayerName = this.param ["layer"];
this.spriteRenderFore.sortingOrder = int.Parse(this.param ["sort"]);
this.spriteRenderBack.sortingLayerName = this.param ["layer"];
this.spriteRenderBack.sortingOrder = int.Parse(this.param ["sort"]);
}
示例5: Start
// Use this for initialization
void Start ()
{
if (TargetSpriteRenderer == null)
{
TargetSpriteRenderer = GetComponentInChildren<SpriteRenderer>();
}
}
示例6: Awake
// Use this for initialization
void Awake()
{
spriteRend = GetComponent<SpriteRenderer> ();
collider = GetComponent<PolygonCollider2D> ();
//DestroyPlanetChunk ();
}
示例7: Awake
/// <summary>
/// Initialize this Class
/// </summary>
public override void Awake()
{
base.Awake();
spriteRenderer = GetComponent<SpriteRenderer>();
startPos = new IntVector2((int)transform.position.x, (int)-transform.position.y);
targetPos = startPos;
}
示例8: OnEnable
private void OnEnable()
{
lightModes = new string[2];
lightModes[0] = @"UnLit";
lightModes[1] = @"BumpLit";
spriteRenderer = this.GetComponent<SpriteRenderer>();
sunLight = this.GetComponent<Light>();
hsbColor = new HSBColor(Color.white);
hsbColor.s = 1.0f;
if (GameObject.Find("FlareSpawner0") != null)
{
flareSpawners.Add(GameObject.Find("FlareSpawner0").GetComponent<Spawner>());
flareSpawners[0].enabled = false;
}
if (GameObject.Find("FlareSpawner1") != null)
{
flareSpawners.Add(GameObject.Find("FlareSpawner1").GetComponent<Spawner>());
flareSpawners[1].enabled = false;
}
if (GameObject.Find("FlareSpawner2") != null)
{
flareSpawners.Add(GameObject.Find("FlareSpawner2").GetComponent<Spawner>());
flareSpawners[2].enabled = false;
}
}
示例9: SetColor
void SetColor(Transform _transform, Color _color)
{
mText = _transform.GetComponent<Text> ();
if (mText != null){
mText.color = _color;
}
mLight = _transform.GetComponent<Light>();
if (mLight != null){
mLight.color = _color;
}
mImage = _transform.GetComponent<Image> ();
if (mImage != null) {
mImage.color = _color;
}
mSpriteRender = _transform.GetComponent<SpriteRenderer> ();
if (mSpriteRender != null) {
mSpriteRender.color = _color;
}
if (_transform.GetComponent<Renderer>() != null) {
mMat = _transform.GetComponent<Renderer>().material;
if (mMat != null) {
mMat.color = _color;
}
}
if (includeChilds) {
for (int i = 0; i < _transform.childCount; ++i) {
Transform child = _transform.GetChild(i);
SetColor(child, _color);
}
}
}
示例10: FadeInLevel
public static void FadeInLevel(SpriteRenderer spriteRenderer, float fadeAfter, float timeToFade)
{
DOTween.Sequence()
.AppendInterval(fadeAfter)
.Append(spriteRenderer.DOFade(0, timeToFade)
.SetEase(Ease.InOutExpo));
}
示例11: Awake
void Awake()
{
_spriteRenderer = GetComponent<SpriteRenderer>();
OnLeftTeam = transform.position.x <= 14.5 ? true : false;
_leftPlayerScript = GameObject.FindGameObjectWithTag("LeftPlayer").GetComponent<BasePlayer>();
_levelManagerScript = Camera.main.GetComponent<LevelManager>();
}
示例12: Awake
private Score score; // Reference to the Score script.
void Awake ()
{
// Setting up the references.
ren = transform.Find ("body").GetComponent<SpriteRenderer> ();
frontCheck = transform.Find ("frontCheck").transform;
score = GameObject.Find ("Score").GetComponent<Score> ();
}
示例13: Start
void Start()
{
_spriteRenderer = GetComponent<SpriteRenderer>();
if (CollectionManager == null)
{
if (FindManagerByReference)
{
var man = FindObjectsOfType<PropertiesCollectionProxyManager>();
foreach (var item in man)
{
if (string.CompareOrdinal(ManagerReferenceId, item.ReferenceId) == 0)
{
CollectionManager = item;
break;
}
}
if (CollectionManager = null)
{
Debug.LogError(string.Format("Could not find an Manager with the Id: {0}", ManagerReferenceId));
}
}
else
{
Debug.LogError("There is no Manager assigned!");
}
}
}
示例14: Awake
// Awake
void Awake()
{
if( Application.isPlaying )
Destroy( this );
mySprite = GetComponent<SpriteRenderer>();
}
示例15: Start
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>();
collider = GetComponent<BoxCollider2D> ();
audioSource = GetComponent<AudioSource> ();
this.FollowPath();
}