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


C# UnityEngine.SpriteRenderer类代码示例

本文整理汇总了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;
            }
        }
开发者ID:phicuong08,项目名称:memorymatch,代码行数:34,代码来源:ScoreAnimation.cs

示例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;

          }
开发者ID:pmer,项目名称:zombie-ninja-attack-craft,代码行数:30,代码来源:Angel.cs

示例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);
			}
		}
开发者ID:fromtons,项目名称:meme-pas-peur_app,代码行数:33,代码来源:Talker.cs

示例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"]);


		}
开发者ID:taroyan,项目名称:JokerScriptTest,代码行数:26,代码来源:ImageObject.cs

示例5: Start

		// Use this for initialization
		void Start () 
		{
            if (TargetSpriteRenderer == null)
            {
                TargetSpriteRenderer = GetComponentInChildren<SpriteRenderer>();
            }
		}
开发者ID:pmer,项目名称:zombie-ninja-attack-craft,代码行数:8,代码来源:CharAnimationController.cs

示例6: Awake

        // Use this for initialization
        void Awake()
        {
            spriteRend = GetComponent<SpriteRenderer> ();
            collider = GetComponent<PolygonCollider2D> ();

            //DestroyPlanetChunk ();
        }
开发者ID:dialcforchris,项目名称:InterstellarmadillosGame,代码行数:8,代码来源:GravityBody.cs

示例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;
 }
开发者ID:Franziskus,项目名称:DiamondJam,代码行数:10,代码来源:SimpleGemVisual.cs

示例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;
      }
    }
开发者ID:zacharymacleod,项目名称:Betrayer,代码行数:31,代码来源:Sun.cs

示例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);
         }
     }
 }
开发者ID:nekodon,项目名称:Pinball,代码行数:31,代码来源:uTweenColor.cs

示例10: FadeInLevel

 public static void FadeInLevel(SpriteRenderer spriteRenderer, float fadeAfter, float timeToFade)
 {
     DOTween.Sequence()
         .AppendInterval(fadeAfter)
         .Append(spriteRenderer.DOFade(0, timeToFade)
         .SetEase(Ease.InOutExpo));
 }
开发者ID:Kurukshetran,项目名称:Unity2D-Components,代码行数:7,代码来源:MFX.cs

示例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>();
 }
开发者ID:arhpositive,项目名称:GGJ2016,代码行数:7,代码来源:RuneTile.cs

示例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> ();
				}
开发者ID:bryanrtboy,项目名称:wireframe-workshop,代码行数:10,代码来源:Enemy.cs

示例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!");
                }
            }
        }
开发者ID:cuongngo90,项目名称:Unity-SpriteShader,代码行数:30,代码来源:PropertiesCollectionProxyController.cs

示例14: Awake

 // Awake
 void Awake()
 {
     if( Application.isPlaying ) 
         Destroy( this ); 
     
     mySprite = GetComponent<SpriteRenderer>();
 }
开发者ID:ifty420,项目名称:Fuel-Truck-Eugene-2,代码行数:8,代码来源:TouchzoneResizeEvents.cs

示例15: Start

		// Use this for initialization
		void Start () {
			spriteRenderer = GetComponent<SpriteRenderer>();
			collider = GetComponent<BoxCollider2D> ();
			audioSource = GetComponent<AudioSource> ();

			this.FollowPath();	
		}
开发者ID:fromtons,项目名称:meme-pas-peur_app,代码行数:8,代码来源:Luciole.cs


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