Ejemplo n.º 1
0
 private void ConvertToSprite()
 {
     spriteList = new List <UISprite>();
     foreach (UITexture tex in targetObj.GetComponentsInChildren <UITexture>(true))
     {
         if (tex.mainTexture == null)
         {
             continue;
         }
         TexSetter setter = tex.GetComponent <TexSetter>();
         TexLoader loader = tex.GetComponent <TexLoader>();
         if (setter != null && setter.textures.Count == 1)
         {
             if (!AssetBundlePath.inst.IsCdnAsset(loader.Target.mainTexture))
             {
                 setter.DestroyEx();
                 loader.DestroyEx();
             }
         }
         if (loader != null)
         {
             continue;
         }
         UIAtlas atlas = atlasMap.Get(tex.mainTexture.name);
         if (atlas != null)
         {
             var s = tex.ConvertToSprite();
             s.atlas = atlas;
             EditorUtil.SetDirty(s.atlas);
             spriteList.Add(s);
         }
     }
 }
Ejemplo n.º 2
0
 public TexLoader GetLoader()
 {
     if (texLoader == null)
     {
         texLoader = GetComponent <TexLoader>();
     }
     return(texLoader);
 }
Ejemplo n.º 3
0
 public static void RestoreTexture(TexLoader l)
 {
     if (l.Target != null && l.editorTexPath.IsNotEmpty())
     {
         l.Target.mainTexture = UnityEditor.AssetDatabase.LoadAssetAtPath(l.editorTexPath, typeof(Texture)) as Texture;
         BuildScript.SetDirty(l.gameObject);
     }
 }
Ejemplo n.º 4
0
        protected override void PreprocessComponent(Component comp)
        {
            TexLoader l = comp as TexLoader;

            if (l.Target != null && l.Target.mainTexture != null)
            {
                ClearTexture(l);
            }
        }
Ejemplo n.º 5
0
 public static bool ClearTexture(TexLoader l)
 {
     if (l.Target != null && l.Target.mainTexture != null)
     {
         l.editorTexPath      = UnityEditor.AssetDatabase.GetAssetPath(l.Target.mainTexture);
         l.Target.mainTexture = null;
         BuildScript.SetDirty(l.Target);
         return(true);
     }
     return(false);
 }
        protected override void VerifyComponent(Component comp)
        {
            UITexture tex = comp as UITexture;
            TexLoader l   = tex.GetComponent <TexLoader>();

            if (tex.mainTexture != null && AssetBundlePath.inst.IsCdnAsset(tex.mainTexture) &&
                (l == null || IsTextureMismatch(tex)))
            {
                TexSetter setter = tex.GetComponentEx <TexSetter>();
                var       aref   = new AssetRef();
                aref.cdn = true;
                aref.SetPath(tex.mainTexture);
                setter.textures.Clear();
                setter.textures.Add(aref);
                BuildScript.SetDirty(comp.gameObject);
                BuildScript.SetDirty(setter);
            }
        }
Ejemplo n.º 7
0
        protected override void DrawCell(object val)
        {
            TexLoader loader = gameObject.GetComponentEx <TexLoader>();

            loader.Load(val as string, null);
        }