Exemplo n.º 1
0
    // Token: 0x060008DE RID: 2270 RVA: 0x00046B40 File Offset: 0x00044D40
    public void AddSprite(object id, string spriteName, Vector2 pos, float width, float height, Color32 color, Vector2 pivot, float rot = 0f, UIBasicSprite.Type type = UIBasicSprite.Type.Simple, UIBasicSprite.Flip flip = UIBasicSprite.Flip.Nothing, bool enabled = true)
    {
        if (this.mAtlas == null)
        {
            Debug.LogError("Atlas must be assigned first");
            return;
        }
        UISpriteCollection.Sprite sprite = default(UISpriteCollection.Sprite);
        INGUIAtlas atlas = this.atlas;

        if (atlas != null)
        {
            sprite.sprite = atlas.GetSprite(spriteName);
        }
        if (sprite.sprite == null)
        {
            return;
        }
        sprite.pos        = pos;
        sprite.rot        = rot;
        sprite.width      = width;
        sprite.height     = height;
        sprite.color      = color;
        sprite.pivot      = pivot;
        sprite.type       = type;
        sprite.flip       = flip;
        sprite.enabled    = enabled;
        this.mSprites[id] = sprite;
        if (enabled && !this.mChanged)
        {
            this.MarkAsChanged();
        }
    }
Exemplo n.º 2
0
 // Token: 0x060008E1 RID: 2273 RVA: 0x00046C4E File Offset: 0x00044E4E
 public bool SetSprite(object id, UISpriteCollection.Sprite sp)
 {
     this.mSprites[id] = sp;
     if (!this.mChanged)
     {
         this.MarkAsChanged();
     }
     return(true);
 }
Exemplo n.º 3
0
    // Token: 0x060008EA RID: 2282 RVA: 0x00046F04 File Offset: 0x00045104
    public UISpriteCollection.Sprite?GetCurrentSprite(Vector3 worldPos)
    {
        Vector2 a = this.mTrans.InverseTransformPoint(worldPos);

        foreach (KeyValuePair <object, UISpriteCollection.Sprite> keyValuePair in this.mSprites)
        {
            UISpriteCollection.Sprite value = keyValuePair.Value;
            Vector2 vector = a - value.pos;
            if (value.rot != 0f)
            {
                vector = UISpriteCollection.Rotate(vector, -value.rot);
            }
            Vector4 drawingDimensions = value.GetDrawingDimensions(this.pixelSize);
            if (vector.x >= drawingDimensions.x && vector.y >= drawingDimensions.y && vector.x <= drawingDimensions.z && vector.y <= drawingDimensions.w)
            {
                return(new UISpriteCollection.Sprite?(keyValuePair.Value));
            }
        }
        return(null);
    }
Exemplo n.º 4
0
    // Token: 0x060008DB RID: 2267 RVA: 0x000466E4 File Offset: 0x000448E4
    public override void OnFill(List <Vector3> verts, List <Vector2> uvs, List <Color> cols)
    {
        Texture mainTexture = this.mainTexture;

        if (mainTexture == null)
        {
            return;
        }
        int     count      = verts.Count;
        Vector4 drawRegion = base.drawRegion;

        foreach (KeyValuePair <object, UISpriteCollection.Sprite> keyValuePair in this.mSprites)
        {
            UISpriteCollection.Sprite value = keyValuePair.Value;
            if (value.enabled)
            {
                this.mSprite = value.sprite;
                if (this.mSprite != null)
                {
                    Color color = value.color;
                    color.a = this.finalAlpha;
                    if (color.a != 0f)
                    {
                        Rect rect  = new Rect((float)this.mSprite.x, (float)this.mSprite.y, (float)this.mSprite.width, (float)this.mSprite.height);
                        Rect rect2 = new Rect((float)(this.mSprite.x + this.mSprite.borderLeft), (float)(this.mSprite.y + this.mSprite.borderTop), (float)(this.mSprite.width - this.mSprite.borderLeft - this.mSprite.borderRight), (float)(this.mSprite.height - this.mSprite.borderBottom - this.mSprite.borderTop));
                        this.mOuterUV = NGUIMath.ConvertToTexCoords(rect, mainTexture.width, mainTexture.height);
                        this.mInnerUV = NGUIMath.ConvertToTexCoords(rect2, mainTexture.width, mainTexture.height);
                        this.mFlip    = value.flip;
                        Vector4 drawingDimensions = value.GetDrawingDimensions(this.pixelSize);
                        Vector4 drawingUVs        = base.drawingUVs;
                        if (this.premultipliedAlpha)
                        {
                            color = NGUITools.ApplyPMA(color);
                        }
                        int count2 = verts.Count;
                        switch (value.type)
                        {
                        case UIBasicSprite.Type.Simple:
                            base.SimpleFill(verts, uvs, cols, ref drawingDimensions, ref drawingUVs, ref color);
                            break;

                        case UIBasicSprite.Type.Sliced:
                            base.SlicedFill(verts, uvs, cols, ref drawingDimensions, ref drawingUVs, ref color);
                            break;

                        case UIBasicSprite.Type.Tiled:
                            base.TiledFill(verts, uvs, cols, ref drawingDimensions, ref color);
                            break;

                        case UIBasicSprite.Type.Filled:
                            base.FilledFill(verts, uvs, cols, ref drawingDimensions, ref drawingUVs, ref color);
                            break;

                        case UIBasicSprite.Type.Advanced:
                            base.AdvancedFill(verts, uvs, cols, ref drawingDimensions, ref drawingUVs, ref color);
                            break;
                        }
                        if (value.rot != 0f)
                        {
                            float f      = value.rot * 0.017453292f * 0.5f;
                            float num    = Mathf.Sin(f);
                            float num2   = Mathf.Cos(f);
                            float num3   = num * 2f;
                            float num4   = num * num3;
                            float num5   = num2 * num3;
                            int   i      = count2;
                            int   count3 = verts.Count;
                            while (i < count3)
                            {
                                Vector3 vector = verts[i];
                                vector    = new Vector3((1f - num4) * vector.x - num5 * vector.y, num5 * vector.x + (1f - num4) * vector.y, vector.z);
                                vector.x += value.pos.x;
                                vector.y += value.pos.y;
                                verts[i]  = vector;
                                i++;
                            }
                        }
                        else
                        {
                            int j      = count2;
                            int count4 = verts.Count;
                            while (j < count4)
                            {
                                Vector3 value2 = verts[j];
                                value2.x += value.pos.x;
                                value2.y += value.pos.y;
                                verts[j]  = value2;
                                j++;
                            }
                        }
                    }
                }
            }
        }
        this.mSprite = null;
        if (this.onPostFill != null)
        {
            this.onPostFill(this, count, verts, uvs, cols);
        }
    }