Ejemplo n.º 1
0
    IEnumerator _coPlay(string packname, string clipname, float fadeOutTime)
    {
        //装入资源包
        List <string> pkList = new List <string>();

        pkList.Add(packname);
        PacketLoader pkLoader = new PacketLoader();

        pkLoader.Start(PackType.Res, pkList, null);
        IEnumerator pkIt     = pkLoader.Wait();
        bool        needWait = true;

        while (needWait)
        {
            try
            {
                needWait = pkIt.MoveNext();
            }
            catch (Exception)
            {
                //装载资源遇到问题
                Debug.Log(string.Format("BackgroundMusic 装载包遇到错误 包:{0}", packname));
                yield break;
            }

            yield return(null);
        }
        //将包加入资源引用管理
        ResourceRefManage.Single.AddRef(packname);

        PacketRouting packetRouting = PacketManage.Single.GetPacket(packname);

        if (packetRouting == null)
        {
            Debug.LogError(string.Format("BackgroundMusicManage.Play 不存在的包 packname:{0} clipname:{1}", packname, clipname));
            yield break;//包不存在
        }
        AudioClip clip = packetRouting.Load(clipname) as AudioClip;

        if (clip == null)
        {
            Debug.LogError(string.Format("BackgroundMusicManage.Play 不存在的音频剪辑 packname:{0} clipname:{1}", packname, clipname));
            yield break;//音频剪辑无效
        }
        if (m_BackgroundMusicObj == null)
        {
            m_BackgroundMusicObj = new GameObject("BackgroundMusic");
            GameObject.DontDestroyOnLoad(m_BackgroundMusicObj);
        }
        //创建一个新的AudioSource来播放
        m_CurrPackname               = packname;
        m_CurrClipname               = clipname;
        m_CurrBackgroundMusic        = m_BackgroundMusicObj.AddComponent <AudioSource>();
        m_CurrBackgroundMusic.clip   = clip;
        m_CurrBackgroundMusic.loop   = true;
        m_CurrBackgroundMusic.volume = 0;
        m_CurrBackgroundMusic.Play();
        CoroutineManage.Single.StartCoroutine(coFadeInBackgroundMusic(fadeOutTime));//淡入背景音
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 设置纹理
    /// </summary>
    /// <param name="lodLevel">0-n  近-远</param>
    /// <param name="textureName">新的纹理名</param>
    public void SetTexture(int lodLevel, string textureName)
    {
        //强制重新设置材质
        IsSetMateriald = false;
        m_CurrMeshLod  = -1;

        var           matIndex = EnableLodTexture ? lodLevel : 0;
        PacketRouting pack     = PacketManage.Single.GetPacket(TexturePackName);

        m_LodMaterial[matIndex] =
            MFAModelManage.Single.GetMaterial(m_LodMaterial[matIndex].shader, pack.Load(textureName) as Texture);
    }
Ejemplo n.º 3
0
    static Material Avatar_Mats_N;                                                                   //角色渲染材质

    public static void Init()
    {
        GameObject Prefabs = GameObject.Find("/Prefabs");

        //Infantry 步兵 Cavalry 骑兵
        //var scene_mainPacket = PacketManage.Single.GetPacket("scene_main");
        //scene_mainPacket.Load("spotlight") as GameObject
        Object3D_Prefabs.Add("spotlight", null);



        PacketRouting pk = PacketManage.Single.GetPacket("core");

        Avatar_ColorMat_N = pk.Load("Avatar_N_Color.mat") as Material;
        Avatar_Mats_N     = pk.Load("Avatar_N.mat") as Material;

        m_AvatarLayer = LayerMask.NameToLayer("Avatar");

        //绑定主场景事件
        DP_BattlefieldDraw.Single.BindMainSceneEvent();
    }
Ejemplo n.º 4
0
    public static GameObject InstantiateFromPacket(string packName, string preObjName, GameObject parent)
    {
        PacketRouting corePack = PacketManage.Single.GetPacket(packName);

        if (corePack == null)
        {
            Debug.LogError(string.Format("_InstantiateFromPacket 包尚未就绪:{0}", packName));
        }

        UnityEngine.Object preObj = corePack.Load(preObjName);
        if (preObj == null)
        {
            Debug.LogError(String.Format("实例化对象错误, packet:{0} preObjName:{1}", packName, preObjName));
        }

        return(InstantiateFromPreobj(preObj, parent));
    }
Ejemplo n.º 5
0
 static int Load(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         PacketRouting           obj  = (PacketRouting)ToLua.CheckObject(L, 1, typeof(PacketRouting));
         string                  arg0 = ToLua.CheckString(L, 2);
         FileSystem.RES_LOCATION arg1 = (FileSystem.RES_LOCATION)ToLua.CheckObject(L, 3, typeof(FileSystem.RES_LOCATION));
         UnityEngine.Object      o    = obj.Load(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }