Esempio n. 1
0
    static public void SetImageSprite(Image img, string name, bool is_nativesize = false)
    {
        if (name == null)
        {
            Debug.LogError("set_icon Image name 不能为 null !");
            return;
        }

        if (img == null)
        {
            Debug.LogError("set_icon Image 不能为 null !");
            return;
        }

        Sprite sp = AssetsPoolManager.Load <Sprite>(name);// LoadSprite(name);

        if (sp != null)
        {
            img.overrideSprite = sp;// Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector3.zero);
            img.sprite         = img.overrideSprite;

            if (is_nativesize)
            {
                img.SetNativeSize();
            }
        }
        else
        {
            Debug.LogError("SetImageSprite 加载失败,查看资源是否存在,图片格式是否正确:" + name);
        }
    }
Esempio n. 2
0
    public static void SetText(Text text, string name, SystemLanguage language)
    {
        if (ContainsData(name, language))
        {
            TextStyleData data = GetTextStyleData(name, language);

            if (!ResourcesConfigManager.GetIsExitRes(data.fontName))
            {
                Debug.LogError("dont find font :" + data.fontName);
            }
            else
            {
                text.font = AssetsPoolManager.Load <Font>(data.fontName);
            }
            text.fontSize             = data.fontSize;
            text.fontStyle            = data.fontStyle;
            text.resizeTextForBestFit = data.bestFit;
            text.resizeTextMinSize    = data.minSize;
            text.resizeTextMaxSize    = data.maxSize;
            text.alignment            = data.alignment;
            text.supportRichText      = data.richText;
            text.horizontalOverflow   = data.horizontalOverflow;
            text.verticalOverflow     = data.verticalOverflow;
            text.lineSpacing          = data.lineSpacing;
        }
    }
Esempio n. 3
0
 private static DataTable LoadDataTable(SystemLanguage language, string fullFileName)
 {
     if (Application.isPlaying)
     {
         string    name = GetLanguageDataName(language, fullFileName);
         TextAsset text = AssetsPoolManager.Load <TextAsset>(name);
         if (text == null)
         {
             Debug.LogError("Error: no Language file :" + name);
             return(null);
         }
         if (loadTextFileTimesDic.ContainsKey(name))
         {
             loadTextFileTimesDic[name]++;
         }
         else
         {
             loadTextFileTimesDic.Add(name, 1);
         }
         DataTable data = DataTable.Analysis(text.text);
         return(data);
     }
     else
     {
         return(LanguageDataUtils.LoadFileData(language, fullFileName));
     }
 }
Esempio n. 4
0
    /// <summary>
    /// 加载一个对象并把它实例化
    /// </summary>
    /// <param name="gameObjectName">对象名</param>
    /// <param name="parent">对象的父节点,可空</param>
    /// <returns></returns>
    private static GameObject NewGameObject(string gameObjectName, GameObject parent = null)
    {
        GameObject goTmp = AssetsPoolManager.Load <GameObject>(gameObjectName);

        if (goTmp == null)
        {
            throw new Exception("CreateGameObject error dont find :" + gameObjectName);
        }

        return(ObjectInstantiate(goTmp, parent));
    }
Esempio n. 5
0
    public AudioClip GetAudioClip(string name)
    {
        AudioClip red = AssetsPoolManager.Load <AudioClip>(name);

        if (red != null)
        {
            return(red);
        }
        Debug.LogError("Can not find AudioClip:" + name);
        return(null);
    }
Esempio n. 6
0
    public static AudioClip GetAudioClip(string soundName)
    {
        AudioClip clipTmp = null;

        clipTmp = AssetsPoolManager.Load <AudioClip>(soundName);

        if (clipTmp == null)
        {
            Debug.LogError("AudioManager GetAudioClip error: " + soundName + "is not AudioClip ! ");
        }

        return(clipTmp);
    }
Esempio n. 7
0
    public static Sprite LoadSprite(string resName)
    {
        Texture2D texture = AssetsPoolManager.Load <Texture2D>(resName);

        if (texture)
        {
            return(Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)));
        }
        else
        {
            Debug.LogError("加载图片失败:" + resName);
            return(null);
        }
    }
Esempio n. 8
0
    private static void Init()
    {
        if (isInit)
        {
            return;
        }
        isInit = true;

        GameObject obj = new GameObject("[AudioGroupSystem]");

        instance = obj.AddComponent <AudioGroupSystem>();

        TextAsset asset = AssetsPoolManager.Load <TextAsset>(ConfigName);

        List <AudioGroupData> datas = JsonUtils.FromJson <List <AudioGroupData> >(asset.text);

        audioGroupDataDic.Clear();
        foreach (var item in datas)
        {
            audioGroupDataDic.Add(item.keyName, item);
        }
    }