static StackObject *GetAudioClip_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Boolean stream = ptr_of_this_method->Value == 1;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Boolean threeD = ptr_of_this_method->Value == 1;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            UnityEngine.WWW www = (UnityEngine.WWW) typeof(UnityEngine.WWW).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = UnityEngine.WWWAudioExtensions.GetAudioClip(www, threeD, stream);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 2
0
        static StackObject *Ctor_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.Generic.Dictionary <System.String, System.String> headers = (System.Collections.Generic.Dictionary <System.String, System.String>) typeof(System.Collections.Generic.Dictionary <System.String, System.String>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Byte[] postData = (System.Byte[]) typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String url = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = new UnityEngine.WWW(url, postData, headers);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 3
0
        public static byte[] ReadAllBytes(string path)
        {
            if (path.Contains("://"))
            {
#if UNITY_ANDROID
                UnityEngine.WWW www = new UnityEngine.WWW(path);

                while (!www.isDone && www.error == null)
                {
                }
                if (www.error != null)
                {
                    Log.Error("load file error + " + www.error);
                    return(null);
                }
                return(www.bytes);
#endif
            }
            return(File.ReadAllBytes(path));
        }
Exemplo n.º 4
0
        public static string ReadAllText(string path)
        {
            if (path.Contains("file://"))
            {
#if UNITY_ANDROID
                Log.Print("Loader", "begin www load");
                UnityEngine.WWW www = new UnityEngine.WWW(path);
                while (!www.isDone && www.error == null)
                {
                }
                if (www.error != null)
                {
                    Log.Error("load file error + " + www.error);
                    return(string.Empty);
                }
                return(www.text);
#endif
            }
            return(File.ReadAllText(path));
        }
Exemplo n.º 5
0
        static int _m_Dispose(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);


            try {
                {
                    __cl_gen_to_be_invoked.Dispose(  );



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 6
0
        public void __Gen_Delegate_Imp8(UnityEngine.WWW p0)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int errFunc    = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
            ObjectTranslator translator = luaEnv.translator;
            translator.Push(L, p0);

            PCall(L, 1, 0, errFunc);



            LuaAPI.lua_settop(L, errFunc - 1);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
        static int LoadFromCacheOrDownload_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    string url     = LuaAPI.lua_tostring(L, 1);
                    int    version = LuaAPI.xlua_tointeger(L, 2);

                    UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(url, version);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    string url     = LuaAPI.lua_tostring(L, 1);
                    int    version = LuaAPI.xlua_tointeger(L, 2);
                    uint   crc     = LuaAPI.xlua_touint(L, 3);

                    UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(url, version, crc);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.LoadFromCacheOrDownload!"));
        }
Exemplo n.º 8
0
        static int _m_LoadImageIntoTexture(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.Texture2D texture = (UnityEngine.Texture2D)translator.GetObject(L, 2, typeof(UnityEngine.Texture2D));

                    __cl_gen_to_be_invoked.LoadImageIntoTexture(texture);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static int _m_GetMovieTexture(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);



                {
                    UnityEngine.MovieTexture __cl_gen_ret = __cl_gen_to_be_invoked.GetMovieTexture(  );
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 10
0
        static int _m_InitWWW(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);


            try {
                {
                    string   url      = LuaAPI.lua_tostring(L, 2);
                    byte[]   postData = LuaAPI.lua_tobytes(L, 3);
                    string[] iHeaders = (string[])translator.GetObject(L, 4, typeof(string[]));

                    __cl_gen_to_be_invoked.InitWWW(url, postData, iHeaders);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 11
0
        // IEnumerator with callback
        static IEnumerator GetWWWCore(string url, IObserver <string> observer, CancellationToken cancellationToken)
        {
            var www = new UnityEngine.WWW(url);

            while (!www.isDone && !cancellationToken.IsCancellationRequested)
            {
                yield return(null);
            }

            if (cancellationToken.IsCancellationRequested)
            {
                yield break;
            }

            if (www.error != null)
            {
                observer.OnError(new Exception(www.error));
            }
            else
            {
                observer.OnNext(www.text);
                observer.OnCompleted();
            }
        }
Exemplo n.º 12
0
        static int _m_WriteFileFromWWW(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                Casinos.LuaMgr gen_to_be_invoked = (Casinos.LuaMgr)translator.FastGetCSObj(L, 1);



                {
                    string          _path = LuaAPI.lua_tostring(L, 2);
                    UnityEngine.WWW _www  = (UnityEngine.WWW)translator.GetObject(L, 3, typeof(UnityEngine.WWW));

                    gen_to_be_invoked.WriteFileFromWWW(_path, _www);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Exemplo n.º 13
0
        static int _m_GetAudioClip(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.WWW gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1)
                {
                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudioClip(  );
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2))
                {
                    bool _threeD = LuaAPI.lua_toboolean(L, 2);

                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudioClip(_threeD);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3))
                {
                    bool _threeD = LuaAPI.lua_toboolean(L, 2);
                    bool _stream = LuaAPI.lua_toboolean(L, 3);

                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudioClip(_threeD, _stream);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 4 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && translator.Assignable <UnityEngine.AudioType>(L, 4))
                {
                    bool _threeD = LuaAPI.lua_toboolean(L, 2);
                    bool _stream = LuaAPI.lua_toboolean(L, 3);
                    UnityEngine.AudioType _audioType; translator.Get(L, 4, out _audioType);

                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudioClip(_threeD, _stream, _audioType);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.GetAudioClip!"));
        }
Exemplo n.º 14
0
        static int _m_LoadFromCacheOrDownload_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    string _url     = LuaAPI.lua_tostring(L, 1);
                    int    _version = LuaAPI.xlua_tointeger(L, 2);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _version);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    string _url     = LuaAPI.lua_tostring(L, 1);
                    int    _version = LuaAPI.xlua_tointeger(L, 2);
                    uint   _crc     = LuaAPI.xlua_touint(L, 3);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _version, _crc);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.Hash128>(L, 2))
                {
                    string _url = LuaAPI.lua_tostring(L, 1);
                    UnityEngine.Hash128 _hash; translator.Get(L, 2, out _hash);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _hash);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.Hash128>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    string _url = LuaAPI.lua_tostring(L, 1);
                    UnityEngine.Hash128 _hash; translator.Get(L, 2, out _hash);
                    uint _crc = LuaAPI.xlua_touint(L, 3);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _hash, _crc);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.CachedAssetBundle>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    string _url = LuaAPI.lua_tostring(L, 1);
                    UnityEngine.CachedAssetBundle _cachedBundle; translator.Get(L, 2, out _cachedBundle);
                    uint _crc = LuaAPI.xlua_touint(L, 3);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _cachedBundle, _crc);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.CachedAssetBundle>(L, 2))
                {
                    string _url = LuaAPI.lua_tostring(L, 1);
                    UnityEngine.CachedAssetBundle _cachedBundle; translator.Get(L, 2, out _cachedBundle);

                    UnityEngine.WWW gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload(_url, _cachedBundle);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.LoadFromCacheOrDownload!"));
        }
Exemplo n.º 15
0
        public static void loadlindenmeshes2(string LODfilename)
        {
            // Already have mashes loaded?
            if (lindenMeshesLoaded) return;

            attachment_points.Clear();

            //on android, Directory.GetCurrentDirectory() returns "/" which means root folder of the system. no folder or file can be added into "/"
            //I change character folder path as follow
            string basedir = Utility.GetCharacterDir();
            UnityEngine.Debug.Log("avatar_lad.xml is in " + basedir);
            XmlDocument lad = new XmlDocument();
            string path = basedir + LODfilename;

            if (!File.Exists(path))
            {
                UnityEngine.Debug.Log(path + " doesn't exist! So we quit");
                UnityEngine.Application.Quit();
            }

            if (path.Contains("://"))
            {
                UnityEngine.WWW www = new UnityEngine.WWW(path);
                while(!www.isDone)
                    ;

                lad.LoadXml(www.text);
            }
            else
                lad.Load(path);
            UnityEngine.Debug.Log("Successfully loaded avatar_lad.xml");
            //Firstly read the skeleton section this contains attachment point info and the bone deform info for visual params
            // And load the skeleton file in to the bones class

            XmlNodeList skeleton = lad.GetElementsByTagName("skeleton");
            string skeletonfilename = skeleton[0].Attributes.GetNamedItem("file_name").Value;
            Bone.loadbones(skeletonfilename);

            // Next read all the skeleton child nodes, we have attachment points and bone deform params
            // attachment points are an offset and rotation from a bone location
            // the name of the bone they reference is the joint paramater
            // params in the skeleton nodes are bone deforms, eg leg length changes the scale of the leg bones

            foreach (XmlNode skeletonnode in skeleton[0].ChildNodes)
            {
                if (skeletonnode.Name == "attachment_point")
                {
                    attachment_point point = new attachment_point(skeletonnode);
                    attachment_points.Add(point.id, point);
                }
            }

            // Parse all visual paramaters in one go
            // we can dedue type on the fly
            XmlNodeList paramss = lad.GetElementsByTagName("param");
            foreach (XmlNode paramNode in paramss)
            {
                VisualParamEx vp = new VisualParamEx(paramNode);
            }

            //Now we parse the mesh nodes, mesh nodes reference a particular LLM file with a LOD

            XmlNodeList meshes = lad.GetElementsByTagName("mesh");
            foreach (XmlNode meshNode in meshes)
            {
                string type = meshNode.Attributes.GetNamedItem("type").Value;
                int lod = Int32.Parse(meshNode.Attributes.GetNamedItem("lod").Value);
                string fileName = meshNode.Attributes.GetNamedItem("file_name").Value;

                GLMesh mesh = null;
                lock (_defaultmeshes)
                    mesh = (_defaultmeshes.ContainsKey(type) ? _defaultmeshes[type] : new GLMesh(type));

                // Set up the texture elemenets for each mesh
                // And hack the eyeball position
                switch (mesh.Name)
                {
                    case "lowerBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.LowerBaked;
                        break;

                    case "upperBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.UpperBaked;
                        break;

                    case "headMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "hairMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HairBaked;
                        break;

                    case "eyelashMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "eyeBallRightMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "eyeBallLeftMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "skirtMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.SkirtBaked;
                        break;

                    default:
                        mesh.teFaceID = 0;
                        break;
                }

                if (lod == 0)
                    mesh.LoadMesh(basedir + fileName);
                else
                    mesh.LoadLODMesh(lod, basedir + fileName);

                if (lod == 0)
                {
                    switch (mesh.Name)
                    {
                        case "eyeBallLeftMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeLeft"].getTotalOffset());
                            break;

                        case "eyeBallRightMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeRight"].getTotalOffset());
                            break;

                        case "eyelashMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        case "hairMesh":
                            //mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        default:
                            break;
                    }
                }

                lock (_defaultmeshes) _defaultmeshes[type] = mesh;

            }

            lindenMeshesLoaded = true;
        }
Exemplo n.º 16
0
 //Load from a local path (starting at resource/
 public static UnityEngine.Texture2D loadTexture(string path)
 {
     UnityEngine.WWW loader = new UnityEngine.WWW(rscUrl + path);
     return(loader.texture);
 }
Exemplo n.º 17
0
        static internal void Lua_UnityEngine_Events_UnityAction_1_UnityEngine_WWW(LuaFunction ld, UnityEngine.WWW a1)
        {
            IntPtr l     = ld.L;
            int    error = pushTry(l);

            pushValue(l, a1);
            ld.pcall(1, error);
            LuaDLL.lua_settop(l, error - 1);
        }
Exemplo n.º 18
0
        internal static int LoadFromStreamingAssetsPath(RealStatePtr L)
        {
            try
            {
                string filename = LuaAPI.lua_tostring(L, 1).Replace('.', '/') + ".lua";
                var filepath = UnityEngine.Application.streamingAssetsPath + "/" + filename;
            #if UNITY_ANDROID && !UNITY_EDITOR
                UnityEngine.WWW www = new UnityEngine.WWW(filepath);
                while (true)
                {
                    if (www.isDone || !string.IsNullOrEmpty(www.error))
                    {
                        System.Threading.Thread.Sleep(50); //�Ƚ�hacker������
                        if (!string.IsNullOrEmpty(www.error))
                        {
                            LuaAPI.lua_pushstring(L, string.Format(
                               "\n\tno such file '{0}' in streamingAssetsPath!", filename));
                        }
                        else
                        {
                            UnityEngine.Debug.LogWarning("load lua file from StreamingAssets is obsolete, filename:" + filename);
                            if (LuaAPI.luaL_loadbuffer(L, www.text, "@" + filename) != 0)
                            {
                                return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}",
                                    LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
                            }
                        }
                        break;
                    }
                }
            #else
                if (File.Exists(filepath))
                {
                    Stream stream = File.Open(filepath, FileMode.Open, FileAccess.Read);
                    StreamReader reader = new StreamReader(stream);
                    string text = reader.ReadToEnd();
                    stream.Close();

                    UnityEngine.Debug.LogWarning("load lua file from StreamingAssets is obsolete, filename:" + filename);
                    if (LuaAPI.luaL_loadbuffer(L, text, "@" + filename) != 0)
                    {
                        return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}",
                            LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
                    }
                }
                else
                {
                    LuaAPI.lua_pushstring(L, string.Format(
                        "\n\tno such file '{0}' in streamingAssetsPath!", filename));
                }
            #endif
                return 1;
            }
            catch (System.Exception e)
            {
                return LuaAPI.luaL_error(L, "c# exception in LoadFromStreamingAssetsPath:" + e);
            }
        }
Exemplo n.º 19
0
 public static string ParseWWWResponse(this UnityEngine.WWW www)
 {
     return(ParseWWWResponse(www, null, 0));
 }
Exemplo n.º 20
0
        public static string ParseWWWResponse(this UnityEngine.WWW www, string token, ulong seq)
        {
            if (www == null)
            {
                return("Invalid request obj.");
            }
            else
            {
                if (!www.isDone)
                {
                    return("Request undone.");
                }
                else
                {
                    if (!string.IsNullOrEmpty(www.error))
                    {
                        return(www.error);
                    }
                    else
                    {
                        string enc       = "";
                        bool   encrypted = false;
                        string txt       = "";
                        if (www.responseHeaders != null)
                        {
                            foreach (var kvp in www.responseHeaders)
                            {
                                var lkey = kvp.Key.ToLower();
                                if (lkey == "content-encoding")
                                {
                                    enc = kvp.Value.ToLower();
                                }
                                else if (lkey == "encrypted")
                                {
                                    var val = kvp.Value;
                                    if (val != null)
                                    {
                                        val = val.ToLower();
                                    }
                                    encrypted = !string.IsNullOrEmpty(val) && val != "n" && val != "0" && val != "f" && val != "no" && val != "false";
                                }
                            }
                        }

                        bool zipHandledBySystem = false;
#if !UNITY_EDITOR && UNITY_IPHONE
                        zipHandledBySystem = true;
#endif
                        if (enc != "gzip" || zipHandledBySystem)
                        {
                            try
                            {
                                txt = www.text;
                                if (encrypted)
                                {
                                    var data      = Convert.FromBase64String(txt);
                                    var decrypted = PlatExt.PlatDependant.DecryptPostData(data, token, seq);
                                    if (decrypted != null)
                                    {
#if NETFX_CORE
                                        txt = System.Text.Encoding.UTF8.GetString(decrypted, 0, decrypted.Length);
#else
                                        txt = System.Text.Encoding.UTF8.GetString(decrypted);
#endif
                                    }
                                }
                            }
                            catch { }
                        }
                        else
                        {
                            try
                            {
                                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(www.bytes, false))
                                {
                                    using (Unity.IO.Compression.GZipStream gs = new Unity.IO.Compression.GZipStream(ms, Unity.IO.Compression.CompressionMode.Decompress))
                                    {
                                        using (var sr = new System.IO.StreamReader(gs))
                                        {
                                            txt = sr.ReadToEnd();
                                        }
                                        if (encrypted)
                                        {
                                            var data      = Convert.FromBase64String(txt);
                                            var decrypted = PlatExt.PlatDependant.DecryptPostData(data, token, seq);
                                            if (decrypted != null)
                                            {
#if NETFX_CORE
                                                txt = System.Text.Encoding.UTF8.GetString(decrypted, 0, decrypted.Length);
#else
                                                txt = System.Text.Encoding.UTF8.GetString(decrypted);
#endif
                                            }
                                        }
                                    }
                                }
                            }
                            catch { }
                        }
                        return(txt);
                    }
                }
            }
        }
Exemplo n.º 21
0
        public void MakeRequest(Batch batch)
        #endif
        {
            Stopwatch watch = new Stopwatch();

            #if UNITY_5_3_OR_NEWER
            string url = this.client.Config.Host + "/v1/import";

            // set the current request time
            batch.SentAt = DateTime.Now.ToString("o");

            string json      = JsonConvert.SerializeObject(batch);
            byte[] jsonBytes = System.Text.UTF8Encoding.UTF8.GetBytes(json);

            var headers = new System.Collections.Generic.Dictionary <string, string>();
            headers.Add("Content-Type", "application/json");
            headers.Add("Authorization", this.BasicAuthHeader(batch.WriteKey, string.Empty));

            var www = new UnityEngine.WWW(url, jsonBytes, headers);

            yield return(www);

            watch.Stop();

            if (string.IsNullOrEmpty(www.error) == false)
            {
                this.Fail(batch, new System.Exception(www.error), watch.ElapsedMilliseconds);
            }
            else
            {
                this.Succeed(batch, watch.ElapsedMilliseconds);
            }
            #else
            try
            {
                Uri uri = new Uri(this.client.Config.Host + "/v1/import");

                // set the current request time
                batch.SentAt = DateTime.Now.ToString("o");

                string json = JsonConvert.SerializeObject(batch, this.settings);

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

                // Basic Authentication
                // https://segment.io/docs/tracking-api/reference/#authentication
                request.Headers["Authorization"] = this.BasicAuthHeader(batch.WriteKey, string.Empty);

                request.Timeout     = (int)this.Timeout.TotalMilliseconds;
                request.ContentType = "application/json";
                request.Method      = "POST";

                // do not use the expect 100-continue behavior
                request.ServicePoint.Expect100Continue = false;

                // buffer the data before sending, ok since we send all in one shot
                request.AllowWriteStreamBuffering = true;

                Logger.Info(
                    "Sending analytics request to Segment.io ..",
                    new Dict
                {
                    { "batch id", batch.MessageId },
                    { "json size", json.Length },
                    { "batch size", batch.Actions.Count }
                });

                watch.Start();

                using (var requestStream = request.GetRequestStream())
                {
                    using (StreamWriter writer = new StreamWriter(requestStream))
                    {
                        writer.Write(json);
                    }
                }

                using (var response = (HttpWebResponse)request.GetResponse())
                {
                    watch.Stop();

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        this.Succeed(batch, watch.ElapsedMilliseconds);
                    }
                    else
                    {
                        string responseStr = string.Format("Status Code {0}. ", response.StatusCode);
                        responseStr += this.ReadResponse(response);
                        this.Fail(batch, new APIException("Unexpected Status Code", responseStr), watch.ElapsedMilliseconds);
                    }
                }
            }
            catch (WebException e)
            {
                watch.Stop();
                this.Fail(batch, this.ParseException(e), watch.ElapsedMilliseconds);
            }
            catch (System.Exception e)
            {
                watch.Stop();
                this.Fail(batch, e, watch.ElapsedMilliseconds);
            }
            #endif
        }
Exemplo n.º 22
0
        public static void loadbones(string skeletonfilename)
        {
            lock (Bone.mBones) mBones.Clear();
            string basedir = Utility.GetCharacterDir();
            //string basedir = Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "character" + System.IO.Path.DirectorySeparatorChar;
            XmlDocument skeleton = new XmlDocument();
            string path = basedir + skeletonfilename;
            if (path.Contains("://"))
            {
                UnityEngine.WWW www = new UnityEngine.WWW(path);
                while(!www.isDone)
                    ;

                skeleton.LoadXml(www.text);
            }
            else
                skeleton.Load(path);
            UnityEngine.Debug.Log ("Successfully loaded bones " + path);
            XmlNode boneslist = skeleton.GetElementsByTagName("linden_skeleton")[0];
            addbone(boneslist.ChildNodes[0], null);
        }