Exemplo n.º 1
0
 public virtual void refresh()
 {
     if (!gameObject.activeInHierarchy || string.IsNullOrEmpty(spriteName))
     {
         return;
     }
     if (mAtlas != null)
     {
         if (mAtlas.isBorrowSpriteMode)               // && mSprite == null) {
         {
             if (mSprite != null && mSprite.name != spriteName)
             {
                 mAtlas.returnSpriteByname(mSprite.name);
                 mSprite = null;
             }
             if (mSprite == null)
             {
                 SetAtlasSprite(mAtlas.borrowSpriteByname(spriteName, this));                                // add by chenbin
                 if (mSprite != null)
                 {
                     if (panel != null)                                              //add by chenbin
                     {
                         panel.RemoveWidget(this);                                   //add by chenbin
                     }
                     if (panel != null)                                              //add by chenbin
                     {
                         panel.AddWidget(this);                                      //add by chenbin
                     }
                     MarkAsChanged();
                 }
             }
             else
             {
                 mSpriteSet = true;                                  // add by chenbin
             }
         }
         else
         {
             if (mSprite == null)
             {
                 SetAtlasSprite(mAtlas.GetSprite(spriteName));
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Display the drop-down list when the game object gets clicked on.
 /// </summary>
 #region add by chenbin
 void OnClick()
 {
     if (atlas != null && atlas.isBorrowSpriteMode)
     {
         if (!string.IsNullOrEmpty(backgroundSprite))
         {
             Callback cb = onGetBackgroundSprite;
             atlas.borrowSpriteByname(backgroundSprite, null, cb);
         }
         else
         {
             doOnClick();
         }
     }
     else
     {
         doOnClick();
     }
 }
Exemplo n.º 3
0
        public void prepareOneSprite4BorrowMode(UIAtlas atlas, string spriteName, object callback, object orgs)
        {
            UISpriteData sd = atlas.getSpriteBorrowMode(spriteName);

            if (sd != null && MapEx.get(UIAtlas.assetBundleMap, sd.path) != null)
            {
                Utl.doCallback(callback, null, spriteName, orgs);
            }
            else
            {
                atlas.borrowSpriteByname(spriteName, null, callback, orgs);
            }
        }
Exemplo n.º 4
0
    bool searchNow   = false; // add by chenbin

    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);

        if (NGUISettings.atlas == null)
        {
            GUILayout.Label("No Atlas selected.", "LODLevelNotifyText");
        }
        else
        {
            UIAtlas atlas = NGUISettings.atlas;
            bool    close = false;
            GUILayout.Label(atlas.name + " Sprites", "LODLevelNotifyText");
            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            GUILayout.Space(84f);

            string before = NGUISettings.partialSprite;
            GUILayout.BeginHorizontal(); // add by chenbin
            {
                string after = EditorGUILayout.TextField("", before, "SearchTextField");
                if (before != after)
                {
                    NGUISettings.partialSprite = after;
                }
                if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
                {
                    searchNow = false;
                    NGUISettings.partialSprite = "";
                    GUIUtility.keyboardControl = 0;
                }
                if (GUILayout.Button("Search", GUILayout.Width(60f))) // add by chenbin
                {
                    searchNow = true;
                }
            }
            GUILayout.EndHorizontal(); // add by chenbin

            GUILayout.Space(84f);
            GUILayout.EndHorizontal();

            Texture2D tex = atlas.texture as Texture2D;

            if (tex == null && !atlas.isBorrowSpriteMode)               //modify by chenbin)
            {
                GUILayout.Label("The atlas doesn't have a texture to work with");
                return;
            }

            if (!searchNow)
            {
                return;
            }
            BetterList <string> sprites = atlas.GetListOfSprites(NGUISettings.partialSprite);

            float size    = 80f;
            float padded  = size + 10f;
            int   columns = Mathf.FloorToInt(Screen.width / padded);
            if (columns < 1)
            {
                columns = 1;
            }

            int  offset = 0;
            Rect rect   = new Rect(10f, 0, size, size);

            GUILayout.Space(10f);
            mPos = GUILayout.BeginScrollView(mPos);
            int rows = 1;

            while (offset < sprites.size)
            {
                GUILayout.BeginHorizontal();
                {
                    int col = 0;
                    rect.x = 10f;

                    for (; offset < sprites.size; ++offset)
                    {
//						UISpriteData sprite = atlas.GetSprite(sprites[offset]);
                        #region add by chenbin
                        UISpriteData sprite = null;
                        if (atlas.isBorrowSpriteMode)
                        {
                            sprite = atlas.borrowSpriteByname(sprites[offset], null);
                            if (sprite != null && sprite.material != null)
                            {
                                tex = sprite.material.mainTexture as Texture2D;
                            }
                        }
                        else
                        {
                            sprite = atlas.GetSprite(sprites[offset]);
                        }
                        #endregion
                        if (sprite == null || tex == null)                          //modify  by chenbin
                        {
                            continue;
                        }

                        // Button comes first
                        if (GUI.Button(rect, ""))
                        {
                            if (Event.current.button == 0)
                            {
                                float delta = Time.realtimeSinceStartup - mClickTime;
                                mClickTime = Time.realtimeSinceStartup;

                                if (NGUISettings.selectedSprite != sprite.name)
                                {
                                    if (mSprite != null)
                                    {
                                        NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite);
                                        mSprite.MakePixelPerfect();
                                        EditorUtility.SetDirty(mSprite.gameObject);
                                    }

                                    NGUISettings.selectedSprite = sprite.name;
                                    NGUIEditorTools.RepaintSprites();
                                    if (mCallback != null)
                                    {
                                        mCallback(sprite.name);
                                    }
                                }
                                else if (delta < 0.5f)
                                {
                                    close = true;
                                }
                            }
                            else
                            {
                                NGUIContextMenu.AddItem("Edit", false, EditSprite, sprite);
                                NGUIContextMenu.AddItem("Delete", false, DeleteSprite, sprite);
                                NGUIContextMenu.Show();
                            }
                        }

                        if (Event.current.type == EventType.Repaint)
                        {
                            // On top of the button we have a checkboard grid
                            NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
                            Rect uv = new Rect(sprite.x, sprite.y, sprite.width, sprite.height);
                            uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);

                            // Calculate the texture's scale that's needed to display the sprite in the clipped area
                            float scaleX = rect.width / uv.width;
                            float scaleY = rect.height / uv.height;

                            // Stretch the sprite so that it will appear proper
                            float aspect   = (scaleY / scaleX) / ((float)tex.height / tex.width);
                            Rect  clipRect = rect;

                            if (aspect != 1f)
                            {
                                if (aspect < 1f)
                                {
                                    // The sprite is taller than it is wider
                                    float padding = size * (1f - aspect) * 0.5f;
                                    clipRect.xMin += padding;
                                    clipRect.xMax -= padding;
                                }
                                else
                                {
                                    // The sprite is wider than it is taller
                                    float padding = size * (1f - 1f / aspect) * 0.5f;
                                    clipRect.yMin += padding;
                                    clipRect.yMax -= padding;
                                }
                            }

                            GUI.DrawTextureWithTexCoords(clipRect, tex, uv);

                            // Draw the selection
                            if (NGUISettings.selectedSprite == sprite.name)
                            {
                                NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
                            }
                        }

                        GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);
                        GUI.contentColor    = new Color(1f, 1f, 1f, 0.7f);
                        GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), sprite.name, "ProgressBarBack");
                        GUI.contentColor    = Color.white;
                        GUI.backgroundColor = Color.white;

                        if (++col >= columns)
                        {
                            ++offset;
                            break;
                        }
                        rect.x += padded;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(padded);
                rect.y += padded + 26;
                ++rows;
            }
            GUILayout.Space(rows * 26);
            GUILayout.EndScrollView();

            if (close)
            {
                Close();
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>

    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);
        mAtlas = target as UIAtlas;

        UISpriteData sprite = (mAtlas != null) ? mAtlas.GetSprite(NGUISettings.selectedSprite) : null;

        GUILayout.Space(6f);

        if (mAtlas.replacement != null)
        {
            mType        = AtlasType.Reference;
            mReplacement = mAtlas.replacement;
        }

        GUILayout.BeginHorizontal();
        AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);

        NGUIEditorTools.DrawPadding();
        GUILayout.EndHorizontal();

        if (mType != after)
        {
            if (after == AtlasType.Normal)
            {
                mType = AtlasType.Normal;
                OnSelectAtlas(null);
            }
            else
            {
                mType = AtlasType.Reference;
            }
        }

        if (mType == AtlasType.Reference)
        {
            ComponentSelector.Draw <UIAtlas>(mAtlas.replacement, OnSelectAtlas, true);

            GUILayout.Space(6f);
            EditorGUILayout.HelpBox("You can have one atlas simply point to " +
                                    "another one. This is useful if you want to be " +
                                    "able to quickly replace the contents of one " +
                                    "atlas with another one, for example for " +
                                    "swapping an SD atlas with an HD one, or " +
                                    "replacing an English atlas with a Chinese " +
                                    "one. All the sprites referencing this atlas " +
                                    "will update their references to the new one.", MessageType.Info);

            if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
            {
                NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
                mAtlas.replacement = mReplacement;
                NGUITools.SetDirty(mAtlas);
            }
            return;
        }

        //GUILayout.Space(6f);
        Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;

        if (mAtlas.spriteMaterial != mat)
        {
            NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
            mAtlas.spriteMaterial = mat;

            // Ensure that this atlas has valid import settings
            if (mAtlas.texture != null)
            {
                NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
            }

            mAtlas.MarkAsChanged();
        }

        #region         //add by chenbin
        if (mAtlas.isBorrowSpriteMode)
        {
            GUI.color = Color.green;
        }
        else
        {
            GUI.color = Color.white;
        }
        GUILayout.Label("\n===	=========================================");
        if (GUILayout.Button("说明"))
        {
            isShowBorrowModeDesc = !isShowBorrowModeDesc;
        }
        if (isShowBorrowModeDesc)
        {
            GUILayout.Label("勾选isBorrowSpriteMode时,表明该atlas是空atlas,\n" +
                            "当有sprit对象来borrow时,atlas会根据名字从\n" +
                            "设置的路径中去取得图片资源。\n" +
                            //"其中资源必须在Resources/下,\n" +
                            "另外atlas必须要引用一个material,\n" +
                            "就算引用的是个空material也行。\n");
        }

        if (mAtlas != null && runTimes == 0)
        {
            runTimes++;
            isBorrowMode = mAtlas.isBorrowSpriteMode;
            //			isUserUnity3DType = mAtlas.useUnity3DType;
        }
        mAtlas.isBorrowSpriteMode = EditorGUILayout.Toggle("isBorrowSpriteMode", mAtlas.isBorrowSpriteMode);
        if (isBorrowMode != mAtlas.isBorrowSpriteMode)
        {
            isBorrowMode = mAtlas.isBorrowSpriteMode;
            UnityEditor.EditorUtility.SetDirty(mAtlas.gameObject);
        }
        //		if (mAtlas.isBorrowSpriteMode) {
        //			mAtlas.useUnity3DType = EditorGUILayout.Toggle ("useUnity3DType", mAtlas.useUnity3DType);
        //			if (isUserUnity3DType != mAtlas.useUnity3DType) {
        //				isUserUnity3DType = mAtlas.useUnity3DType;
        //				UnityEditor.EditorUtility.SetDirty (NGUISettings.atlas.gameObject);
        //			}
        //		}
        GUILayout.Label("============================================\n");
        GUI.color = Color.white;
        if (GUILayout.Button("Clean items if no png"))
        {
            if (EditorUtility.DisplayDialog("Alert", "Really ?", "Do it now!", "NO"))
            {
                UISpriteData        item = null;
                List <UISpriteData> list = new List <UISpriteData> ();
                for (int i = 0; i < mAtlas.spriteList.Count; i++)
                {
                    item = mAtlas.spriteList [i];
                    string path = Application.dataPath + "/" + item.path;
                    path = path.Replace("/upgradeRes/", "/upgradeRes4Dev/");
                    path = path.Replace("/upgradeRes4Publish/", "/upgradeRes4Dev/");
                    if (!File.Exists(path))
                    {
                        Debug.Log(path);
                        list.Add(item);
                    }
                }
                deleteSprites(list);
            }
        }
        #endregion                                    //end ======add by chenbin

        if (mat != null || mAtlas.isBorrowSpriteMode) // modify by chenbin
        {
            TextAsset ta = EditorGUILayout.ObjectField("TP Import", null, typeof(TextAsset), false) as TextAsset;

            if (ta != null)
            {
                // Ensure that this atlas has valid import settings
                if (mAtlas.texture != null)
                {
                    NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
                }

                NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
                NGUIJson.LoadSpriteData(mAtlas, ta);
                if (sprite != null)
                {
                    sprite = mAtlas.GetSprite(sprite.name);
                }
                mAtlas.MarkAsChanged();
            }

            float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));

            if (pixelSize != mAtlas.pixelSize)
            {
                NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
                mAtlas.pixelSize = pixelSize;
            }
        }

        if (mAtlas.spriteMaterial != null || mAtlas.isBorrowSpriteMode)                 //modify by chenbin
        {
            Color blueColor  = new Color(0f, 0.7f, 1f, 1f);
            Color greenColor = new Color(0.4f, 1f, 0f, 1f);

            if (sprite == null && mAtlas.spriteList.Count > 0)
            {
                string spriteName = NGUISettings.selectedSprite;
                if (!string.IsNullOrEmpty(spriteName))
                {
                    sprite = mAtlas.GetSprite(spriteName);
                }
//				if (sprite == null) sprite = mAtlas.spriteList[0];  // delete by chenbin
                #region add by chenbin
                if (sprite == null)
                {
                    if (mAtlas.isBorrowSpriteMode)
                    {
                        sprite     = mAtlas.spriteList [0];
                        spriteName = sprite.name;
                        sprite     = mAtlas.borrowSpriteByname(spriteName, null);
                    }
                    else
                    {
                        sprite = mAtlas.spriteList [0];
                    }
                }
                #endregion
            }

            if (sprite != null)
            {
                if (sprite == null)
                {
                    return;
                }

//				Texture2D tex = mAtlas.spriteMaterial.mainTexture as Texture2D;	//delete by chenbin
                #region add by chenbin
                Texture2D tex = null;
                if (mAtlas != null)
                {
                    if (mAtlas.isBorrowSpriteMode)
                    {
                        if (sprite != null && sprite.material != null)
                        {
                            tex = sprite.material.mainTexture as Texture2D;
                        }
                    }
                    else
                    {
                        tex = mAtlas.spriteMaterial.mainTexture as Texture2D;
                    }
                }
                #endregion


//				if (tex != null)		//modify by chenbin
                if (tex != null || (mAtlas != null && mAtlas.isBorrowSpriteMode && sprite != null))                  //modify by chenbin
                {
                    if (!NGUIEditorTools.DrawHeader("Sprite Details"))
                    {
                        return;
                    }

                    NGUIEditorTools.BeginContents();

                    GUILayout.Space(3f);
                    NGUIEditorTools.DrawAdvancedSpriteField(mAtlas, sprite.name, SelectSprite, true);
                    GUILayout.Space(6f);

                    GUI.changed = false;

                    GUI.backgroundColor = greenColor;
                    NGUIEditorTools.IntVector sizeA = NGUIEditorTools.IntPair("Dimensions", "X", "Y", sprite.x, sprite.y);
                    NGUIEditorTools.IntVector sizeB = NGUIEditorTools.IntPair(null, "Width", "Height", sprite.width, sprite.height);

                    EditorGUILayout.Separator();
                    GUI.backgroundColor = blueColor;
                    NGUIEditorTools.IntVector borderA = NGUIEditorTools.IntPair("Border", "Left", "Right", sprite.borderLeft, sprite.borderRight);
                    NGUIEditorTools.IntVector borderB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.borderBottom, sprite.borderTop);

                    EditorGUILayout.Separator();
                    GUI.backgroundColor = Color.white;
                    NGUIEditorTools.IntVector padA = NGUIEditorTools.IntPair("Padding", "Left", "Right", sprite.paddingLeft, sprite.paddingRight);
                    NGUIEditorTools.IntVector padB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.paddingBottom, sprite.paddingTop);

                    if (GUI.changed)
                    {
                        NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);

                        sprite.x      = sizeA.x;
                        sprite.y      = sizeA.y;
                        sprite.width  = sizeB.x;
                        sprite.height = sizeB.y;

                        sprite.paddingLeft   = padA.x;
                        sprite.paddingRight  = padA.y;
                        sprite.paddingBottom = padB.x;
                        sprite.paddingTop    = padB.y;

                        sprite.borderLeft   = borderA.x;
                        sprite.borderRight  = borderA.y;
                        sprite.borderBottom = borderB.x;
                        sprite.borderTop    = borderB.y;

                        MarkSpriteAsDirty();
                    }

                    GUILayout.Space(3f);

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button("Duplicate"))
                    {
                        string newName = UIAtlasMaker.DuplicateSprite(mAtlas, sprite.name);                         // modify by chenbin
                        if (newName != null)
                        {
                            NGUISettings.selectedSprite = newName;                                              // modify by chenbin
                        }
                    }

                    if (GUILayout.Button("Save As..."))
                    {
#if UNITY_3_5
                        string path = EditorUtility.SaveFilePanel("Save As",
                                                                  NGUISettings.currentPath, sprite.name + ".png", "png");
#else
                        string path = EditorUtility.SaveFilePanelInProject("Save As",
                                                                           sprite.name + ".png", "png",
                                                                           "Extract sprite into which file?", NGUISettings.currentPath);
#endif

                        if (!string.IsNullOrEmpty(path))
                        {
                            NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path);
                            UIAtlasMaker.SpriteEntry se = UIAtlasMaker.ExtractSprite(mAtlas, sprite.name);

                            if (se != null)
                            {
                                byte[] bytes = se.tex.EncodeToPNG();
                                File.WriteAllBytes(path, bytes);
                                AssetDatabase.ImportAsset(path);
                                if (se.temporaryTexture)
                                {
                                    DestroyImmediate(se.tex);
                                }
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                    NGUIEditorTools.EndContents();
                }

                if (NGUIEditorTools.DrawHeader("Modify"))
                {
                    NGUIEditorTools.BeginContents();

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(20f);
                    EditorGUILayout.BeginVertical();

                    NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor);

                    if (GUILayout.Button("Add a Shadow"))
                    {
                        AddShadow(sprite);
                    }
                    if (GUILayout.Button("Add a Soft Outline"))
                    {
                        AddOutline(sprite);
                    }

                    if (GUILayout.Button("Add a Transparent Border"))
                    {
                        AddTransparentBorder(sprite);
                    }
                    if (GUILayout.Button("Add a Clamped Border"))
                    {
                        AddClampedBorder(sprite);
                    }
                    if (GUILayout.Button("Add a Tiled Border"))
                    {
                        AddTiledBorder(sprite);
                    }
                    EditorGUI.BeginDisabledGroup(!sprite.hasBorder);
                    if (GUILayout.Button("Crop Border"))
                    {
                        CropBorder(sprite);
                    }
                    EditorGUI.EndDisabledGroup();

                    EditorGUILayout.EndVertical();
                    GUILayout.Space(20f);
                    EditorGUILayout.EndHorizontal();

                    NGUIEditorTools.EndContents();
                }

                if (NGUIEditorTools.previousSelection != null)
                {
                    GUILayout.Space(3f);
                    GUI.backgroundColor = Color.green;

                    if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name))
                    {
                        NGUIEditorTools.SelectPrevious();
                    }
                    GUI.backgroundColor = Color.white;
                }
            }
        }
    }
Exemplo n.º 6
0
    public UISpriteData borrowSpriteByname(string name, UISprite uisp, object callback, object args)
    {
        if (name == null)
        {
            return(null);
        }

        if (mReplacement != null)
        {
            return(mReplacement.borrowSpriteByname(name, uisp, callback, args));
        }

        //      Debug.Log ("borrow name==" + name);
        int i = spriteMap [name] == null ? -1 : (int)spriteMap [name];

        if (i < 0)
        {
                        #if UNITY_EDITOR
            Debug.LogWarning("can't find sprite ,name=[" + name + "],objname = [" + (uisp != null ? uisp.name : "") + "]");
                        #endif
            Coolape.Utl.doCallback(callback, uisp, name, args);
            return(null);
        }

        //      Sprite ret = sprites.Count > i ? sprites [i] : null;
        UISpriteData ret = mSprites.Count > i ? mSprites [i] : null;
        if (ret == null)
        {
                        #if UNITY_EDITOR
            Debug.LogWarning("can't find sprite ,name=[" + name + "]");
                        #endif
            Coolape.Utl.doCallback(callback, uisp, name, args);
            return(ret);
        }

        isBorrowSprite = true;
        int rc = retainCounter [ret.path] == null ? 0 : (int)(retainCounter [ret.path]);

        if (ret.material == null || ret.material.mainTexture == null || assetBundleMap [ret.path] == null)
        {
//			rc = 0;
            Texture tt = null;
            try {
                if (assetBundleMap [ret.path] == null)
                {
                                        #if UNITY_EDITOR
                    if (Application.isPlaying)
                    {
                        getTuxture(ret, uisp, callback, args);
                        isBorrowSprite = false;
                        return(null);
                    }
                    else
                    {
                        string path = ret.path;
                        path = path.Replace("/upgradeRes/", "/upgradeRes4Publish/");
                        path = path.Replace("/upgradeRes4Publish/", "/upgradeRes4Dev/");
                        assetBundleMap [ret.path] = Coolape.CLVerManager.self.getAtalsTexture4Edit(path);
                    }
                                        #else
                    getTuxture(ret, uisp, callback, args);
                    isBorrowSprite = false;
                    return(null);
                                        #endif
                }
                if (assetBundleMap [ret.path] == null)
                {
                    Debug.LogError(ret.path + " is null . name == " + name);
                    isBorrowSprite = false;
                    return(null);
                }
            } catch (Exception e) {
                isBorrowSprite = false;
                Debug.LogError(e);
                return(null);
            }

                        #if UNITY_EDITOR
            if (Application.isPlaying)
            {
                if (assetBundleMap[ret.path] is AssetBundle)
                {
                    tt = (assetBundleMap[ret.path] as AssetBundle).mainAsset as Texture;
                }
                else
                {
                    getTuxture(ret, uisp, callback, args);
                    isBorrowSprite = false;
                    return(null);
                }
            }
            else
            {
                if (assetBundleMap [ret.path].GetType() != typeof(Texture) &&
                    assetBundleMap [ret.path].GetType() != typeof(Texture2D))
                {
                    assetBundleMap [ret.path] = null;
                    return(null);
                }
                tt = (Texture)(assetBundleMap [ret.path]);
            }
                        #else
            //tt = (Texture)(assetBundleMap [ret.path]);
            tt = (assetBundleMap [ret.path] as AssetBundle).mainAsset as Texture;
                        #endif
            if (tt != null)
            {
                if (ret.material == null)
                {
                    ret.material = getMaterail(tt, ret.path);
                }
                else
                {
                    ret.material.mainTexture = tt;
                }
            }
            else
            {
                assetBundleMap [ret.path] = null;
                                #if UNITY_EDITOR
                Debug.LogWarning("can't find Texture in Resource path :[" + ret.path + "]");
                                #endif
                return(null);
            }
        }

        rc++;
        retainCounter [ret.path] = rc;
        isBorrowSprite           = false;
                #if UNITY_EDITOR
        if (Coolape.CLAssetsManager.self != null &&
            !string.IsNullOrEmpty(Coolape.CLAssetsManager.self.debugKey) &&
            ret.path.Contains(Coolape.CLAssetsManager.self.debugKey))
        {
            Debug.LogError("borrow Sprite==" + ret.path + "==" + name + "====" + rc);
        }
                #endif
        Coolape.Utl.doCallback(callback, uisp, ret.name, args);
                #if UNITY_EDITOR
        Coolape.Utl.doCallback(onBorrowSpriteCallback, this, ret);
                #endif
        return(ret);
    }