Ejemplo n.º 1
1
 public static void FadeInLevel(SpriteRenderer spriteRenderer, float fadeAfter, float timeToFade)
 {
     DOTween.Sequence()
         .AppendInterval(fadeAfter)
         .Append(spriteRenderer.DOFade(0, timeToFade)
         .SetEase(Ease.InOutExpo));
 }
Ejemplo n.º 2
0
 /// <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;
 }
Ejemplo n.º 3
0
 protected override void AwakeInitialize()
 {
     base.AwakeInitialize();
     t = transform;
     spriteRender = GetComponent<SpriteRenderer>();
     coll2D = GetComponent<Collider2D>();
 }
Ejemplo n.º 4
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.SpriteRenderer o;
     o = new UnityEngine.SpriteRenderer();
     pushObject(l, o);
     return(1);
 }
        // Use this for initialization
        void Awake()
        {
            spriteRend = GetComponent<SpriteRenderer> ();
            collider = GetComponent<PolygonCollider2D> ();

            //DestroyPlanetChunk ();
        }
Ejemplo n.º 6
0
				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> ();
				}
		// Use this for initialization
		void Start () 
		{
            if (TargetSpriteRenderer == null)
            {
                TargetSpriteRenderer = GetComponentInChildren<SpriteRenderer>();
            }
		}
Ejemplo n.º 8
0
		// 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);
			}
		}
Ejemplo n.º 9
0
 public void Awake()
 {
     if (spriteRenderer == null)
     {
         spriteRenderer = GetComponent <UnityEngine.SpriteRenderer>();
     }
 }
Ejemplo n.º 10
0
    // read input, change graphics
    public void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            if (!isDead)
            {
                if (!this.gameStarted)
                {
                    UnityEngine.SpriteRenderer renderer = startButton.GetComponent <SpriteRenderer>();
                    UnityEngine.SpriteRenderer rend     = gameOver.GetComponent <SpriteRenderer>();

                    rend.enabled     = false;
                    renderer.enabled = false;

                    this.forwordSpeed       = 0.6f;
                    this.rbody.gravityScale = 1.5f;
                    this.animator.enabled   = true;
                }
                this.didFlap = true;
            }
            else
            {
                score = 0;
                UnityEngine.SceneManagement.SceneManager.LoadScene("Play");
            }
        }
    }
Ejemplo n.º 11
0
 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);
         }
     }
 }
Ejemplo n.º 12
0
    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;
      }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Immediately update the visible sprite.
    /// </summary>

    void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null)
        {
            mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
            mNguiSprite  = GetComponent <UI2DSprite>();

            if (mUnitySprite == null && mNguiSprite == null)
            {
                enabled = false;
                return;
            }
        }

        float time = ignoreTimeScale ? RealTime.time : Time.time;

        if (framerate != 0)
        {
            mUpdate = time + Mathf.Abs(1f / framerate);
        }

        if (mUnitySprite != null)
        {
            mUnitySprite.sprite = frames[frameIndex];
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = frames[frameIndex];
        }
    }
Ejemplo n.º 14
0
          //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;

          }
Ejemplo n.º 15
0
		// Use this for initialization
		void Start () {
			spriteRenderer = GetComponent<SpriteRenderer>();
			collider = GetComponent<BoxCollider2D> ();
			audioSource = GetComponent<AudioSource> ();

			this.FollowPath();	
		}
Ejemplo n.º 16
0
		public void Create( string gameObjectName, Transform parentTransform, int sortingOrder )
		{
			spriteGameObject = CreateSpriteGameObject( gameObjectName, parentTransform );
			spriteRenderer = CreateSpriteRenderer( spriteGameObject, idleSprite, sortingOrder );
			spriteRenderer.color = idleColor;
			Ready = true;
		}
Ejemplo n.º 17
0
        private void Start()
		{
			_cameraTransform = transform;

            _mapRenderer = GameObject.Find("BaseMap").GetComponent<SpriteRenderer>();
            _bounds = _mapRenderer.sprite.bounds;
            _bounds.center = _mapRenderer.transform.position;

            _cameraTransform.position = new Vector3(_mapRenderer.transform.position.x, _mapRenderer.transform.position.y, -10);

			_basePosition = _cameraTransform.position;

			_offset = Vector3.zero;

            _camera = GetComponent<UnityEngine.Camera>();
            _windowaspect = (float)Screen.width / (float)Screen.height;
            _widthSize = _camera.orthographicSize * _windowaspect;
            SetBounds(_camera.orthographicSize);

            _camera.orthographicSize = _maxZoom;
            _zoom = _maxZoom;

            _pixelToUnitX = _widthSize * 2 / (float)Screen.width;
            _pixelToUnitY = _camera.orthographicSize * 2 / (float)Screen.height;


        }
Ejemplo n.º 18
0
        private void Awake()
        {
            _spriteRenderer = GetComponent<SpriteRenderer>();

            if (Sprites == null || Sprites.Length == 0)
            {
                Debug.LogWarning("Sprites to chose from is not set: " + gameObject);
                return;
            }
            Sprite randomSprite = Sprites[Random.Range(0, Sprites.Length)];
            if (HorizontalFlip)
            {
                bool needFlip = Random.Range(0, 100) > 50;
                if (needFlip)
                {
                    transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y,
                        transform.localScale.z);
                }
            }

            if (VerticalFlip)
            {
                bool needFlip = Random.Range(0, 100) > 50;
                if (needFlip)
                {
                    transform.localScale = new Vector3(transform.localScale.x, -transform.localScale.y,
                        transform.localScale.z);
                }
            }
            _spriteRenderer.sprite = randomSprite;
        }
Ejemplo n.º 19
0
 public static void Fade(SpriteRenderer element, float fadeTo, float fadeAfter, float timeToFade)
 {
     DOTween.Sequence()
         .AppendInterval(fadeAfter)
         .Append(element.DOFade(fadeTo, timeToFade)
         .SetEase(Ease.InOutExpo));
 }
Ejemplo n.º 20
0
		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"]);


		}
Ejemplo n.º 21
0
        protected override void UpdateMeshData(bool forceUpdate = false)
        {
            if (_meshRenderer == null || _meshFilter == null || IsPartOfStaticBatch)
                return;

            if (GameSpriteRenderer != null && (GameSpriteRenderer != _oldGameSpriteRenderer || forceUpdate ||
                (_oldUnitySprite != null && _oldUnitySprite.sprite != null && _oldUnitySprite.sprite != Sprite) ||
                (_oldCustomSprite != null && _oldCustomSprite.Sprite != null && _oldCustomSprite.Sprite != Sprite)))
            {
                _oldGameSpriteRenderer = GameSpriteRenderer;

                _oldCustomSprite = GameSpriteRenderer.GetComponent<CustomSprite>();
                if (_oldCustomSprite != null)
                {
                    Sprite = _oldCustomSprite.Sprite;
                }
                else
                {
                    _oldUnitySprite = GameSpriteRenderer.GetComponent<SpriteRenderer>();
                    if (_oldUnitySprite != null)
                        Sprite = _oldUnitySprite.sprite;
                }

                Material.EnableKeyword("NORMAL_TEXCOORD");
            }

            if (_oldSecondaryColor != AdditiveColor || forceUpdate)
            {
                UpdateSecondaryColor();
                _isMeshDirty = true;
                _oldSecondaryColor = AdditiveColor;
            }

            base.UpdateMeshData(forceUpdate);
        }
Ejemplo n.º 22
0
        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;
            }
        }
Ejemplo n.º 23
0
    /// <summary>
    /// Immediately update the visible sprite.
    /// </summary>

    void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null)
        {
            mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
            mNguiSprite  = GetComponent <UI2DSprite>();

            if (mUnitySprite == null && mNguiSprite == null)
            {
                enabled = false;
                return;
            }
        }

        float time = ignoreTimeScale ? RealTime.time : Time.time;

        if (framerate != 0)
        {
            mUpdate = time + Mathf.Abs(1f / framerate);
        }

        mIndex = Mathf.Clamp(mIndex, 0, animations[currentAnimation].frames.Length - 1);

        if (mUnitySprite != null)
        {
            mUnitySprite.sprite = animations[currentAnimation].frames[mIndex];
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = animations[currentAnimation].frames[mIndex];;
        }
    }
        private void InitManager()
        {
            //First check if we have any Properties Collections in our array
            if (PropCollections.Length == 0)
            {
                Debug.LogError("There are no Properties Collections assigned!");
                return;
            }
            else
            {
                //Check if none of the Slots in the array is empty/null
                for (int i = 0; i < PropCollections.Length; i++)
                {
                    if (PropCollections[i] == null)
                    {
                        Debug.LogError(string.Format("No Properties Collection assigned at Element {0}!", i));
                        return;
                    }
                }
            }

            //We cache the Materials by our Properties Collections
            _spriteRenderer = GetComponent<SpriteRenderer>();
            InitMaterialCache(_spriteRenderer.sharedMaterial, _cachedMaterials);
        }
        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!");
                }
            }
        }
Ejemplo n.º 26
0
 void Awake()
 {
     _spriteRenderer = GetComponent<SpriteRenderer>();
     OnLeftTeam = transform.position.x <= 14.5 ? true : false;
     _leftPlayerScript = GameObject.FindGameObjectWithTag("LeftPlayer").GetComponent<BasePlayer>();
     _levelManagerScript = Camera.main.GetComponent<LevelManager>();
 }
Ejemplo n.º 27
0
		public override void init(Dictionary<string,string> param){


			this.param = param;

			GameObject g = Resources.Load(GameSetting.PATH_PREFAB + "Clickable") as GameObject;
			this.rootObject = (GameObject)Instantiate(g,new Vector3(0,0f,-3.2f),Quaternion.identity); 
			this.rootObject.name = this.name;

			this.image = g;

			this.spriteRenderImage = this.image.GetComponent<SpriteRenderer> ();

			//this.targetSprite = this.spriteRenderImage.sprite;

			Color tmp = this.spriteRenderImage.color;
			tmp.a = float.Parse (this.param ["a"]);

			//ソート位置を調整
			this.rootObject.GetComponent<SpriteRenderer> ().sortingOrder = int.Parse (this.param["sort"]);
			this.rootObject.GetComponent<SpriteRenderer> ().color = tmp;
			//this.spriteRenderImage.color = tmp;
			//透明度を設定できる


		}
Ejemplo n.º 28
0
        protected override void Awake()
        {
            base.Awake();

            _targetSpriteRenderer =
                _parentObject.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
        }
 // Awake
 void Awake()
 {
     if( Application.isPlaying ) 
         Destroy( this ); 
     
     mySprite = GetComponent<SpriteRenderer>();
 }
Ejemplo n.º 30
0
        protected virtual void Awake()
        {
            renderer = GetComponent<SpriteRenderer>();
            collider = GetComponent<BoxCollider2D>();

            bulletPool = BulletPool.Instance;
            enemyPool = EnemyPool.Instance;
        }
 static public int set_color(IntPtr l)
 {
     UnityEngine.SpriteRenderer o = (UnityEngine.SpriteRenderer)checkSelf(l);
     UnityEngine.Color          v;
     checkType(l, 2, out v);
     o.color = v;
     return(0);
 }
 static public int set_sprite(IntPtr l)
 {
     UnityEngine.SpriteRenderer o = (UnityEngine.SpriteRenderer)checkSelf(l);
     UnityEngine.Sprite         v;
     checkType(l, 2, out v);
     o.sprite = v;
     return(0);
 }
Ejemplo n.º 33
0
		private void Awake()
		{
			_spriteRenderer = GetComponent<SpriteRenderer>();
			_boxCollider2d = GetComponent<BoxCollider2D>();

			var child = transform.FindChild("Outside");
			_outsideBoxCollider2d = child.GetComponent<BoxCollider2D>();
		}
Ejemplo n.º 34
0
 private Vector2 GetRandomCoinPos(SpriteRenderer platformSR)
 {
     //TODO: verify that no coins overlap
     Bounds bounds = platformSR.bounds;
     return new Vector2(
         bounds.min.x + Random.Range(0, bounds.size.x),
         bounds.max.y + Random.Range(jumpHeight / 5, jumpHeight));
 }
Ejemplo n.º 35
0
        // Use this for initialization
        void Start()
        {
            _mpMotor = GetComponent<MovingPlatformMotor2D>();
            _mpMotor.onPlatformerMotorContact += PlayerContact;

            _renderer = GetComponent<SpriteRenderer>();
            _originalColor = _renderer.color;
        }
		/// <summary>
		/// Apply the configuration to the specified renderer.
		/// </summary>
		public void Apply( SpriteRenderer renderer )
		{
			renderer.sprite 							= spriteAsset;
			renderer.gameObject.transform.localPosition = translation;
			renderer.gameObject.transform.localScale    = scale;
			renderer.gameObject.transform.rotation      = Quaternion.Euler( rotation );
			renderer.color								= defaultColor;
		}
Ejemplo n.º 37
0
        void Awake()
        {
            m_spriteRenderer = GetComponent<SpriteRenderer> ();

            int index = Random.Range (0, m_sprites.Length);

            m_spriteRenderer.sprite = m_sprites[index];
        }
Ejemplo n.º 38
0
 void Start()
 {
     mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
     mNguiSprite  = GetComponent <UI2DSprite>();
     if (framerate > 0)
     {
         mUpdate = (ignoreTimeScale ? RealTime.time : Time.time) + 1f / framerate;
     }
 }
Ejemplo n.º 39
0
 static public int get_size(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         pushValue(l, self.size);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 40
0
 static public int get_drawMode(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         pushEnum(l, (int)self.drawMode);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 41
0
 static public int get_adaptiveModeThreshold(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         pushValue(l, self.adaptiveModeThreshold);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 42
0
 static public int get_color(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         pushValue(l, self.color);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 43
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer o;
         o = new UnityEngine.SpriteRenderer();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_maskInteraction(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.maskInteraction);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 45
0
 static public int set_maskInteraction(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer        self = (UnityEngine.SpriteRenderer)checkSelf(l);
         UnityEngine.SpriteMaskInteraction v;
         checkEnum(l, 2, out v);
         self.maskInteraction = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.SpriteRenderer o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.SpriteRenderer();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Ejemplo n.º 47
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer o;
         o = new UnityEngine.SpriteRenderer();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 48
0
 static public int set_adaptiveModeThreshold(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.adaptiveModeThreshold = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 49
0
 static public int set_drawMode(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         UnityEngine.SpriteDrawMode v;
         checkEnum(l, 2, out v);
         self.drawMode = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 50
0
 static public int set_flipY(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.flipY = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 51
0
 static public int set_size(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         UnityEngine.Vector2        v;
         checkType(l, 2, out v);
         self.size = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 52
0
 static public int set_color(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         UnityEngine.Color          v;
         checkType(l, 2, out v);
         self.color = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int set_sprite(IntPtr l)
 {
     try {
         UnityEngine.SpriteRenderer self = (UnityEngine.SpriteRenderer)checkSelf(l);
         UnityEngine.Sprite         v;
         checkType(l, 2, out v);
         self.sprite = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 54
0
        public static void Mask(Light2D light, LightCollider2D id, Material material, LayerSetting layerSetting)
        {
            if (id.InLight(light) == false)
            {
                return;
            }

            Texture2D currentTexture = null;
            Color     currentColor   = Color.black;

            GL.Begin(GL.QUADS);

            foreach (LightColliderShape shape in id.shapes)
            {
                UnityEngine.SpriteRenderer spriteRenderer = shape.spriteShape.GetSpriteRenderer();

                Sprite sprite = shape.spriteShape.GetOriginalSprite();
                if (sprite == null || spriteRenderer == null)
                {
                    continue;
                }

                if (sprite.texture == null)
                {
                    continue;
                }

                Vector2 position = shape.transform2D.position - light.transform2D.position;
                Color   color    = LayerSettingColor.Get(shape, position, layerSetting, id.maskEffect, id.maskTranslucency);

                if (currentTexture != sprite.texture || currentColor != color)
                {
                    currentTexture = sprite.texture;
                    currentColor   = color;

                    material.mainTexture = currentTexture;
                    material.color       = currentColor;

                    material.SetPass(0);
                }

                Rendering.Universal.Sprite.FullRect.DrawPass(id.spriteMeshObject, spriteRenderer, position, shape.transform2D.scale, shape.transform2D.rotation);
            }

            GL.End();

            material.mainTexture = null;
            material.color       = Color.white;
        }
 static void SpriteRenderer_flipY(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
         var result = _this.flipY;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean             arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
         _this.flipY = arg0;
     }
 }
 static void SpriteRenderer_color(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
         var result = _this.color;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Color          arg0  = (UnityEngine.Color)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
         _this.color = arg0;
     }
 }
Ejemplo n.º 57
0
 protected override void Init()
 {
     if (null == m_target)
     {
         return;
     }
     // end if
     m_SpriteRenderer = m_target.GetComponent <UnityEngine.SpriteRenderer>();
     if (null == m_SpriteRenderer)
     {
         return;
     }
     // end if
     m_beginColor = m_SpriteRenderer.color;
 }
Ejemplo n.º 58
0
    static int get_flipY(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SpriteRenderer obj = (UnityEngine.SpriteRenderer)o;
            bool ret = obj.flipY;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index flipY on a nil value"));
        }
    }
Ejemplo n.º 59
0
    static int get_maskInteraction(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SpriteRenderer        obj = (UnityEngine.SpriteRenderer)o;
            UnityEngine.SpriteMaskInteraction ret = obj.maskInteraction;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index maskInteraction on a nil value"));
        }
    }
Ejemplo n.º 60
0
    /// <summary>
    /// Immediately update the visible sprite.
    /// </summary>

    void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null && pImage == null)
        {
            mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
            mNguiSprite  = GetComponent <UI2DSprite>();
            pImage       = GetComponent <UnityEngine.UI.Image>();

            if (mUnitySprite == null && mNguiSprite == null && pImage == null)
            {
                enabled = false;
                return;
            }
        }

        float time = ignoreTimeScale ? RealTime.time : Time.time;

        if (framerate != 0)
        {
            mUpdate = time + Mathf.Abs(1f / framerate);
        }

        if (mUnitySprite != null)
        {
            mUnitySprite.sprite = frames[frameIndex];

            if (_pBoxCollider != null)
            {
                Vector3 vecSize       = mUnitySprite.bounds.size;
                Vector3 vecLocalScale = transform.lossyScale;
                vecSize.x           /= vecLocalScale.x;
                vecSize.y           /= vecLocalScale.x;
                vecSize.z           /= vecLocalScale.y;
                _pBoxCollider.size   = new Vector3(vecSize.x, vecSize.z, vecSize.y);
                _pBoxCollider.center = new Vector3(0f, vecSize.z / 2f);
            }
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = frames[frameIndex];
        }
        else if (pImage != null)
        {
            pImage.sprite = frames[frameIndex];
        }
    }