UIAtlas.GetSprite C# (CSharp) Метод

GetSprite() публичный Метод

Convenience function that retrieves a sprite by name.
public GetSprite ( string name ) : UISpriteData,
name string
Результат UISpriteData,
	public UISpriteData GetSprite (string name)
	{
		if (mReplacement != null)
		{
			return mReplacement.GetSprite(name);
		}
		else if (!string.IsNullOrEmpty(name))
		{
			if (mSprites.Count == 0) Upgrade();

			for (int i = 0, imax = mSprites.Count; i < imax; ++i)
			{
				UISpriteData s = mSprites[i];

				// string.Equals doesn't seem to work with Flash export
				if (!string.IsNullOrEmpty(s.name) && name == s.name)
					return s;
			}
		}
		return null;
	}

Usage Example

 public bool Validate(UIAtlas atlas)
 {
     if (atlas == null)
     {
         return false;
     }
     if (!this.mIsValid)
     {
         if (string.IsNullOrEmpty(this.spriteName))
         {
             return false;
         }
         this.mSprite = (atlas == null) ? null : atlas.GetSprite(this.spriteName);
         if (this.mSprite != null)
         {
             Texture texture = atlas.texture;
             if (texture == null)
             {
                 this.mSprite = null;
             }
             else
             {
                 this.mUV = new Rect((float) this.mSprite.x, (float) this.mSprite.y, (float) this.mSprite.width, (float) this.mSprite.height);
                 this.mUV = NGUIMath.ConvertToTexCoords(this.mUV, texture.width, texture.height);
                 this.mOffsetX = this.mSprite.paddingLeft;
                 this.mOffsetY = this.mSprite.paddingTop;
                 this.mWidth = this.mSprite.width;
                 this.mHeight = this.mSprite.height;
                 this.mAdvance = this.mSprite.width + (this.mSprite.paddingLeft + this.mSprite.paddingRight);
                 this.mIsValid = true;
             }
         }
     }
     return (this.mSprite != null);
 }
All Usage Examples Of UIAtlas::GetSprite