コード例 #1
0
ファイル: BundleManager.cs プロジェクト: swordlegend/army_ru
 public static void DumpAll()
 {
     LogUtil.Debug("BundleManager.DumpAll:");
     DumpBundleRefs();
     DumpBundleLoadHistories();
     DumpBundleLists();
 }
コード例 #2
0
ファイル: BundleManager.cs プロジェクト: swordlegend/army_ru
        public static void DumpBundleLists()
        {
            LogUtil.Debug("---------------------------------------------------------");
            LogUtil.Debug("listAssetBundleUris:");
            foreach (string uri in listAssetBundleUris)
            {
                LogUtil.Debug("uri=" + uri);
            }

            LogUtil.Debug("---------------------------------------------------------");
            LogUtil.Debug("loadingBundles:");
            foreach (string uri in loadingBundles)
            {
                LogUtil.Debug("uri=" + uri);
            }

            LogUtil.Debug("---------------------------------------------------------");
            LogUtil.Debug("tempUriList:");
            foreach (string uri in tempUriList)
            {
                LogUtil.Debug("uri=" + uri);
            }

            LogUtil.Debug("curUnloadIndex=" + curUnloadIndex);
        }
コード例 #3
0
ファイル: SpriteAsset.cs プロジェクト: swordlegend/army_ru
 public void Dump()
 {
     foreach (var pair in _sprites)
     {
         LogUtil.Debug(pair.Key);
         LogUtil.Debug(pair.Value.name);
     }
 }
コード例 #4
0
        /* ====================================================== */

        private static void selfTest()
        {
            byte[][] testData = new byte[4][];
            testData[0] = new byte[]
            {
                0xDE, 0xAD, 0xBE, // EF
            };
            testData[1] = new byte[]
            {
                0x00, 0x01, 0xA2, 0xB3, 0xC4, 0xD5, 0xE6, 0xF7,
            };
            testData[2] = new byte[]
            {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
            };
            testData[3] = new byte[]
            {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
                0xFF,
            };

            foreach (Encoding enc in Enum.GetValues(typeof(Encoding)))
            {
                if (enc == Encoding.Unity || enc == Encoding.Unknown)
                {
                    continue;
                }

                var testLength = testData.Length;
                for (int j = 0; j < testLength; j++)
                {
                    byte[] data       = testData[j];
                    var    dataLength = data.Length;
                    byte[] temp       = new byte[dataLength];
                    Array.Copy(data, temp, dataLength);
                    MemoryStream ms = new MemoryStream();
                    EncodeStream(ms, temp, enc);
                    byte[] decrypted = DecodeData(ms.GetBuffer(), 0, ms.Length);
                    ms.Close();

                    for (int i = 0; i < dataLength; i++)
                    {
                        if (data[i] != decrypted[i])
                        {
                            throw new Exception("BundlerEncoder selfTest: fail at " + enc + " data " + j + " index " + i);
                        }
                    }

                    LogUtil.Debug("BundleEncoder selfTest: success with " + enc + " data " + j);
                }
            }
        }
コード例 #5
0
ファイル: FileUtils.cs プロジェクト: swordlegend/army_ru
        // Prepare the path of asset bundle file in file system
        // Android just needs to modify the path a bit when loading bundle from streaming assets
        public static string PrepareBundleFile(string path)
        {
#if PROFILE_FILE
            Profiler.BeginSample("FileUtils.PrepareBundleFile");
#endif
            var length = searchPaths.Count;
            for (int i = 0; i < length; ++i)
            {
                string p          = searchPaths[i];
                string fullpath   = p + path;
                string actualPath = null;

#if UNITY_ANDROID && !UNITY_EDITOR
                // For android, copy bundle from streaming assets to update path
                if (IsFileExistsInPersistentData(fullpath, out actualPath))
                {
                    LogUtil.Debug("PrepareBundleFile: found in persistent path " + fullpath);
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(actualPath);
                }
                else if (IsFileExistsInStreamingAssets(fullpath))
                {
                    string fixedPath = Application.dataPath + "!assets/" + fullpath;
                    LogUtil.Debug("PrepareBundleFile: found in streaming assets " + fullpath + " fixed: " + fixedPath);
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(fixedPath);
                }
                else if (IsFileExistsInRawPath(fullpath, out actualPath))
                {
                    LogUtil.Debug("PrepareBundleFile: found in raw path " + fullpath);
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(actualPath);
                }
#else
                if (IsFileExistsNoSearching(fullpath, out actualPath))
                {
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(actualPath);
                }
#endif // UNITY_ANDROID
            }

            throw new Exception("PrepareBundleFile: cannot find file " + path);
        }
コード例 #6
0
ファイル: BundleManager.cs プロジェクト: swordlegend/army_ru
 public static void DumpBundleLoadHistories()
 {
     LogUtil.Debug("---------------------------------------------------------");
     LogUtil.Debug("BundleLoadHistories:");
     foreach (KeyValuePair <string, AssetBundleLoadHistory> pair in dictAssetBundleLoadHistories)
     {
         var abLoadHistory = pair.Value;
         LogUtil.Debug("key=" + pair.Key +
                       " uri=" + abLoadHistory.uri +
                       " loadTimes=" + abLoadHistory.loadTimes +
                       " unloadTimes=" + abLoadHistory.unloadTimes);
     }
 }
コード例 #7
0
ファイル: BundleManager.cs プロジェクト: swordlegend/army_ru
 public static void DumpBundleRefs()
 {
     LogUtil.Debug("---------------------------------------------------------");
     LogUtil.Debug("BundleRefs:");
     foreach (KeyValuePair <string, AssetBundleRef> pair in dictAssetBundleRefs)
     {
         var abRef = pair.Value;
         LogUtil.Debug("key=" + pair.Key +
                       " uri=" + abRef.uri +
                       " endTime=" + abRef.EndTime +
                       " secondsToLive=" + abRef.SecondsToLive);
     }
 }
コード例 #8
0
        public void OnApplicationPause(bool pauseStatus)
        {
            LogUtil.Debug("== App paused: " + pauseStatus);
            paused = pauseStatus;

            if (paused)
            {
                AppLifecycle.PauseApp();
            }
            else
            {
                AppLifecycle.ResumeApp();
            }
        }
コード例 #9
0
        void Start()
        {
            LogUtil.Debug("Start ShowStats");

            f_LastInterval = Time.realtimeSinceStartup;

            i_Frames = 0;

            DontDestroyOnLoad(this.gameObject);

            if (!Debug.isDebugBuild)
            {
                this.enabled = false;
            }
        }
コード例 #10
0
ファイル: LuaBridge.cs プロジェクト: swordlegend/army_ru
        public IEnumerator waitForDebugConnection(Action complete)
        {
            lgo.skipDebugger = false;
            LogUtil.Debug("Waiting for debug connection");
            while (true)
            {
                yield return(new WaitForSeconds(0.1f));

                if (lgo.skipDebugger)
                {
                    break;
                }
            }
            complete();
        }
コード例 #11
0
        public static Encoding GetEncodingOfFile(string filepath)
        {
#if MULTI_ENCODING
            LogUtil.Debug("GetEncodingOfFile: MULTI_ENCODING enabled");
            const long headerSize = 2;
            long       bytesRead  = 0;
            byte []    data       = FileUtils.GetDataFromFile(filepath, 0, headerSize, out bytesRead);
            if (bytesRead == headerSize)
            {
                return(GetEncodingOfData(data));
            }
            return(Encoding.Unknown);
#else
            return(Encoding.Unity);
#endif // MULTI_ENCODING
        }
コード例 #12
0
        public static bool CopyFileFromAppJar(string srcfile, string dstfile, bool overwrite)
        {
            if (!overwrite && File.Exists(dstfile))
            {
                LogUtil.Debug("FileUtilsAndroid: copyDataFromAppJarFile dstfile already exists! " + dstfile);
                return(false);
            }

            int res = copyDataFromAppJarFile(srcfile, dstfile, 0, 0);

            if (res == 0)
            {
                return(true);
            }
            else
            {
                LogUtil.Error("FileUtilsAndroid: copyDataFromAppJarFile failed! res=" + res);
                return(false);
            }
        }
コード例 #13
0
        // TODO avoid coping data from C heap to managed heap
        //      maybe optimize by getting file length and preallocate in C#
        public static byte [] ReadDataFromAppJar(string path, long readOffset, long readSize, out long bytesRead)
        {
#if PROFILE_FILE
            Profiler.BeginSample("FileUtilsAndroid.ReadDataFromAppJar");
#endif
            IntPtr L = IntPtr.Zero;

            try
            {
                L = readDataFromAppJarFile(path, readOffset, readSize);
                if (L != IntPtr.Zero)
                {
                    long size = Marshal.ReadInt64(L);
                    LogUtil.Debug("read from jar, size is " + size +
                                  " readOffset is " + readOffset + " readSize is " + readSize);
                    byte [] data = new byte[size];
                    Marshal.Copy(new IntPtr(L.ToInt64() + sizeof(Int64)), data, 0, (int)size);
                    bytesRead = size;
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(data);
                }
                else
                {
                    LogUtil.Error("FileUtilsAndroid: read from jar failed! " + path);
                    bytesRead = 0;
#if PROFILE_FILE
                    Profiler.EndSample();
#endif
                    return(null);
                }
            }
            finally
            {
                if (L != IntPtr.Zero)
                {
                    freeData(L);
                }
            }
        }
コード例 #14
0
ファイル: ClientSocket.cs プロジェクト: swordlegend/army_ru
        //------------------ Sync Interfaces ------------------//

        public bool Connect()
        {
            if (sock != null)
            {
                LogUtil.Debug("ClientSocket.Connect: close first");
                return(false);
            }

            IPEndPoint remoteEP = null;

            initSocket(out remoteEP);

            try {
                sock.Connect(remoteEP);
                return(true);
            }
            catch (SocketException e)
            {
                LogUtil.ErrorFormat("ClientSocket.Connect: {0}", e.ToString());
            }

            return(false);
        }
コード例 #15
0
        void StartLua()
        {
            ComponentReflectionExt.Init();
            var luaBridge      = LBootApp.luaBridge;
            var runDebugScript = luaBridge.DoString("return rawget(_G, 'SCRIPT') == 'debug'");

            if (true.Equals(runDebugScript))
            {
                LogUtil.Debug("running debug scripts");
                var    fname        = "debug.lua";
                byte[] scriptSource = FileUtils.GetDataFromStreamingAssets(fname);
                luaBridge.DoBuffer(scriptSource, fname);
            }
            else
            {
                LogUtil.Debug("running compiled scripts");
                var    fname        = "cl.lc";
                byte[] scriptSource = FileUtils.GetDataFromStreamingAssets(fname);
                luaBridge.DoAesBuffer(scriptSource, fname, LBootApp.LUA_KEY, LBootApp.LUA_IV);
                luaBridge.Call("__main", new object[1] {
                    ""
                });
            }

// 4 times faster for FastGetter FastSetter than using reflection
//            var go = new GameObject("hello");
//            var t = go.transform;
//            t.position = Vector3.one;
//            var startTime = Time.realtimeSinceStartup;
//            object value = null;
//            for (var i = 0; i < 1000; i++)
//            {
//                var positionProperty = ReflectionHelper.GetProperty(t.GetType(), "position");
//                value = positionProperty.GetValue(t, null);
//            }
//            Debug.LogError("Reflection getter position=" + value.ToString());
//            var time = Time.realtimeSinceStartup;
//            Debug.LogError("reflection getter duration = " + ((time - startTime) * 1000).ToString() + "(ms)");
//
//            startTime = Time.realtimeSinceStartup;
//
//            for (var i = 0; i < 1000; i++)
//            {
//                 value = ComponentReflectionExt.FastGetter(t, "position");
//            }
//            Debug.LogError("FastGetter position=" + value.ToString());
//
//            time = Time.realtimeSinceStartup;
//            Debug.LogError("Component FastGetter duration = " + ((time - startTime) * 1000).ToString() + "(ms)");
//
//            var angle = Vector3.one * 100;
//            startTime = Time.realtimeSinceStartup;
//            for (var i = 0; i < 1000; i++)
//            {
//                var positionProperty = ReflectionHelper.GetProperty(t.GetType(), "localEulerAngles");
//                positionProperty.SetValue(t, angle, null);
//            }
//
//            time = Time.realtimeSinceStartup;
//            Debug.LogError("reflection setter localEulerAngles=" + t.localEulerAngles.ToString());
//            Debug.LogError("reflection setter duration = " + ((time - startTime) * 1000).ToString() + "(ms)");
//            t.localEulerAngles = Vector3.one;
//            angle = new Vector3(199, 199, 199);
//            startTime = Time.realtimeSinceStartup;
//            for (var i = 0; i < 1000; i++)
//            {
//                ComponentReflectionExt.FastSetter(t, "localEulerAngles", angle);
//            }
//
//            time = Time.realtimeSinceStartup;
//            Debug.LogError("FastGetter localEulerAngles=" + t.localEulerAngles.ToString());
//            Debug.LogError("Component FastSetter duration = " + ((time - startTime) * 1000).ToString() + "(ms)");
        }
コード例 #16
0
 public static void RestartApp(bool withUpdate)
 {
     LogUtil.Debug("== RestartApp");
     new RestartApp(withUpdate).Restart();
 }
コード例 #17
0
 public static void PauseApp()
 {
     LogUtil.Debug("== PauseApp");
     new PauseApp().Pause();
 }
コード例 #18
0
 public static void ResumeApp()
 {
     LogUtil.Debug("== ResumeApp");
     new ResumeApp().Resume();
 }
コード例 #19
0
        public void ReceivedMemoryWarning(string message)
        {
            LogUtil.Debug("== App ReceivedMemoryWarning: " + message);

            AppLifecycle.ReceivedMemoryWarning();
        }
コード例 #20
0
        public void OnApplicationQuit()
        {
            LogUtil.Debug("== App quit: ");

            AppLifecycle.ShutdownApp();
        }
コード例 #21
0
 public static void ShutdownApp()
 {
     LogUtil.Debug("== ShutdownApp");
     new ShutdownApp().Shutdown();
 }
コード例 #22
0
        // public void OnLevelWasLoaded(int levelId)
        // {
        //     LogUtil.Debug("== Level Loaded: " + Application.loadedLevelName);
        // }

        public void OnDestroy()
        {
            LBootApp.Instance = null;
            LogUtil.Debug("== App destroy: ");
        }
コード例 #23
0
        public void Start()
        {
            LogUtil.Debug("== App start: ");

            AppLifecycle.BootstrapApp(this.gameObject);
        }
コード例 #24
0
 public static void ReceivedMemoryWarning()
 {
     LogUtil.Debug("== ReceivedMemoryWarning");
     new ReceivedMemoryWarning().Notify();
 }
コード例 #25
0
 public static void BootstrapApp(GameObject initGameObject)
 {
     LogUtil.Debug("== BootstrapApp");
     new BootstrapApp(initGameObject).Bootstrap();
 }