Upgrade() private method

Performs an upgrade from the legacy way of specifying data to the new one.
private Upgrade ( ) : bool
return bool
Example #1
0
    /// <summary>
    /// Performs an upgrade from the legacy way of specifying data to the new one.
    /// </summary>

    bool Upgrade()
    {
        if (mReplacement)
        {
            return(mReplacement.Upgrade());
        }

        if (mSprites.Count == 0 && sprites.Count > 0 && material)
        {
            Texture tex    = material.mainTexture;
            int     width  = (tex != null) ? tex.width : 512;
            int     height = (tex != null) ? tex.height : 512;

            for (int i = 0; i < sprites.Count; ++i)
            {
                Sprite old   = sprites[i];
                Rect   outer = old.outer;
                Rect   inner = old.inner;

                if (mCoordinates == Coordinates.TexCoords)
                {
                    NGUIMath.ConvertToPixels(outer, width, height, true);
                    NGUIMath.ConvertToPixels(inner, width, height, true);
                }

                UISpriteData sd = new UISpriteData
                {
                    name = old.name,

                    x      = Mathf.RoundToInt(outer.xMin),
                    y      = Mathf.RoundToInt(outer.yMin),
                    width  = Mathf.RoundToInt(outer.width),
                    height = Mathf.RoundToInt(outer.height),

                    paddingLeft   = Mathf.RoundToInt(old.paddingLeft * outer.width),
                    paddingRight  = Mathf.RoundToInt(old.paddingRight * outer.width),
                    paddingBottom = Mathf.RoundToInt(old.paddingBottom * outer.height),
                    paddingTop    = Mathf.RoundToInt(old.paddingTop * outer.height),

                    borderLeft   = Mathf.RoundToInt(inner.xMin - outer.xMin),
                    borderRight  = Mathf.RoundToInt(outer.xMax - inner.xMax),
                    borderBottom = Mathf.RoundToInt(outer.yMax - inner.yMax),
                    borderTop    = Mathf.RoundToInt(inner.yMin - outer.yMin)
                };

                mSprites.Add(sd);
            }
            sprites.Clear();
#if UNITY_EDITOR
            NGUITools.SetDirty(this);
            UnityEditor.AssetDatabase.SaveAssets();
#endif
            return(true);
        }
        return(false);
    }
Example #2
0
 private bool Upgrade()
 {
     //IL_0053: Unknown result type (might be due to invalid IL or missing references)
     //IL_0058: Expected O, but got Unknown
     //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
     //IL_00af: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b8: Unknown result type (might be due to invalid IL or missing references)
     //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
     //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
     //IL_00d1: Unknown result type (might be due to invalid IL or missing references)
     //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
     if (Object.op_Implicit(mReplacement))
     {
         return(mReplacement.Upgrade());
     }
     if (mSprites.Count == 0 && sprites.Count > 0 && Object.op_Implicit(material))
     {
         Texture val    = material.get_mainTexture();
         int     width  = (!(val != null)) ? 512 : val.get_width();
         int     height = (!(val != null)) ? 512 : val.get_height();
         for (int i = 0; i < sprites.Count; i++)
         {
             Sprite sprite = sprites[i];
             Rect   outer  = sprite.outer;
             Rect   inner  = sprite.inner;
             if (mCoordinates == Coordinates.TexCoords)
             {
                 NGUIMath.ConvertToPixels(outer, width, height, true);
                 NGUIMath.ConvertToPixels(inner, width, height, true);
             }
             UISpriteData uISpriteData = new UISpriteData();
             uISpriteData.name          = sprite.name;
             uISpriteData.x             = Mathf.RoundToInt(outer.get_xMin());
             uISpriteData.y             = Mathf.RoundToInt(outer.get_yMin());
             uISpriteData.width         = Mathf.RoundToInt(outer.get_width());
             uISpriteData.height        = Mathf.RoundToInt(outer.get_height());
             uISpriteData.paddingLeft   = Mathf.RoundToInt(sprite.paddingLeft * outer.get_width());
             uISpriteData.paddingRight  = Mathf.RoundToInt(sprite.paddingRight * outer.get_width());
             uISpriteData.paddingBottom = Mathf.RoundToInt(sprite.paddingBottom * outer.get_height());
             uISpriteData.paddingTop    = Mathf.RoundToInt(sprite.paddingTop * outer.get_height());
             uISpriteData.borderLeft    = Mathf.RoundToInt(inner.get_xMin() - outer.get_xMin());
             uISpriteData.borderRight   = Mathf.RoundToInt(outer.get_xMax() - inner.get_xMax());
             uISpriteData.borderBottom  = Mathf.RoundToInt(outer.get_yMax() - inner.get_yMax());
             uISpriteData.borderTop     = Mathf.RoundToInt(inner.get_yMin() - outer.get_yMin());
             mSprites.Add(uISpriteData);
         }
         sprites.Clear();
         return(true);
     }
     return(false);
 }
Example #3
0
    // Token: 0x060006FE RID: 1790 RVA: 0x00039630 File Offset: 0x00037830
    private bool Upgrade()
    {
        INGUIAtlas replacement = this.replacement;

        if (replacement != null)
        {
            UIAtlas uiatlas = replacement as UIAtlas;
            if (uiatlas != null)
            {
                return(uiatlas.Upgrade());
            }
        }
        if (this.mSprites.Count == 0 && this.sprites.Count > 0 && this.material)
        {
            Texture mainTexture = this.material.mainTexture;
            int     width       = (mainTexture != null) ? mainTexture.width : 512;
            int     height      = (mainTexture != null) ? mainTexture.height : 512;
            for (int i = 0; i < this.sprites.Count; i++)
            {
                UIAtlas.Sprite sprite = this.sprites[i];
                Rect           outer  = sprite.outer;
                Rect           inner  = sprite.inner;
                if (this.mCoordinates == UIAtlas.Coordinates.TexCoords)
                {
                    NGUIMath.ConvertToPixels(outer, width, height, true);
                    NGUIMath.ConvertToPixels(inner, width, height, true);
                }
                UISpriteData uispriteData = new UISpriteData();
                uispriteData.name          = sprite.name;
                uispriteData.x             = Mathf.RoundToInt(outer.xMin);
                uispriteData.y             = Mathf.RoundToInt(outer.yMin);
                uispriteData.width         = Mathf.RoundToInt(outer.width);
                uispriteData.height        = Mathf.RoundToInt(outer.height);
                uispriteData.paddingLeft   = Mathf.RoundToInt(sprite.paddingLeft * outer.width);
                uispriteData.paddingRight  = Mathf.RoundToInt(sprite.paddingRight * outer.width);
                uispriteData.paddingBottom = Mathf.RoundToInt(sprite.paddingBottom * outer.height);
                uispriteData.paddingTop    = Mathf.RoundToInt(sprite.paddingTop * outer.height);
                uispriteData.borderLeft    = Mathf.RoundToInt(inner.xMin - outer.xMin);
                uispriteData.borderRight   = Mathf.RoundToInt(outer.xMax - inner.xMax);
                uispriteData.borderBottom  = Mathf.RoundToInt(outer.yMax - inner.yMax);
                uispriteData.borderTop     = Mathf.RoundToInt(inner.yMin - outer.yMin);
                this.mSprites.Add(uispriteData);
            }
            this.sprites.Clear();
            return(true);
        }
        return(false);
    }
Example #4
0
 private bool Upgrade()
 {
     if ((bool)mReplacement)
     {
         return(mReplacement.Upgrade());
     }
     if (mSprites.Count == 0 && sprites.Count > 0 && (bool)material)
     {
         Texture mainTexture = material.mainTexture;
         int     width       = (!(mainTexture != null)) ? 512 : mainTexture.width;
         int     height      = (!(mainTexture != null)) ? 512 : mainTexture.height;
         for (int i = 0; i < sprites.Count; i++)
         {
             Sprite sprite = sprites[i];
             Rect   outer  = sprite.outer;
             Rect   inner  = sprite.inner;
             if (mCoordinates == Coordinates.TexCoords)
             {
                 NGUIMath.ConvertToPixels(outer, width, height, round: true);
                 NGUIMath.ConvertToPixels(inner, width, height, round: true);
             }
             UISpriteData uISpriteData = new UISpriteData();
             uISpriteData.name          = sprite.name;
             uISpriteData.x             = Mathf.RoundToInt(outer.xMin);
             uISpriteData.y             = Mathf.RoundToInt(outer.yMin);
             uISpriteData.width         = Mathf.RoundToInt(outer.width);
             uISpriteData.height        = Mathf.RoundToInt(outer.height);
             uISpriteData.paddingLeft   = Mathf.RoundToInt(sprite.paddingLeft * outer.width);
             uISpriteData.paddingRight  = Mathf.RoundToInt(sprite.paddingRight * outer.width);
             uISpriteData.paddingBottom = Mathf.RoundToInt(sprite.paddingBottom * outer.height);
             uISpriteData.paddingTop    = Mathf.RoundToInt(sprite.paddingTop * outer.height);
             uISpriteData.borderLeft    = Mathf.RoundToInt(inner.xMin - outer.xMin);
             uISpriteData.borderRight   = Mathf.RoundToInt(outer.xMax - inner.xMax);
             uISpriteData.borderBottom  = Mathf.RoundToInt(outer.yMax - inner.yMax);
             uISpriteData.borderTop     = Mathf.RoundToInt(inner.yMin - outer.yMin);
             mSprites.Add(uISpriteData);
         }
         sprites.Clear();
         return(true);
     }
     return(false);
 }