static int set_logMessageReceived(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Application.set_logMessageReceived");
#endif
        try
        {
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'UnityEngine.Application.logMessageReceived' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.Application'"));
            }

            if (arg0.op == EventOp.Add)
            {
                UnityEngine.Application.LogCallback ev = (UnityEngine.Application.LogCallback)arg0.func;
                UnityEngine.Application.logMessageReceived += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                UnityEngine.Application.LogCallback ev = (UnityEngine.Application.LogCallback)arg0.func;
                UnityEngine.Application.logMessageReceived -= ev;
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#2
0
 void Push_UnityEngine_Application_LogCallback(IntPtr L, UnityEngine.Application.LogCallback o)
 {
     ToLua.Push(L, o);
 }
示例#3
0
 public static void RegisterLogCallbackThreaded(UnityEngine.Application.LogCallback handler)
 {
     UnityEngine.Application.RegisterLogCallbackThreaded(handler);
 }
示例#4
0
            private void Setup(Type target)
            {
                var instance = Activator.CreateInstance(target);
                var fields   = instance.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);

                fieldActions = new Dictionary <NameAndType, Action <object> >();
                var fieldParams = new List <object>();

                /*
                 *      collect fields.
                 */
                foreach (var field in fields)
                {
                    var fieldName = field.Name;
                    var fieldType = field.FieldType;

                    {
                        var             f   = field;
                        Action <object> act = null;

                        switch (fieldType.ToString())
                        {
                        case "System.Boolean": {
                            act = obj => {
                                f.SetValue(instance, (bool)obj);
                            };
                            break;
                        }

                        case "System.String": {
                            act = obj => {
                                f.SetValue(instance, (string)obj);
                            };
                            break;
                        }

                        default: {
                            if (field.FieldType.IsEnum)
                            {
                                act = obj => f.SetValue(instance, Convert.ChangeType(obj, field.FieldType));
                                break;
                            }

                            // ignore.
                            break;
                        }
                        }

                        fieldActions[new NameAndType(fieldName, fieldType)] = act;
                        fieldParams.Add(field.GetValue(instance));
                    }

                    // set default params.
                    param = fieldParams.Select(v => (object)v).ToArray();
                }

                /*
                 *      collect methods.
                 */
                methodActions = new Dictionary <string, Action>();

                var methods = instance.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

                foreach (var method in methods)
                {
                    var len = method.GetParameters().Length;
                    if (0 < len)
                    {
                        continue;
                    }

                    var methodName = method.Name;
                    methodActions[methodName] = () => {
                        method.Invoke(instance, null);
                    };
                }

                /*
                 *      collect logs of target class.
                 */
                UnityEngine.Application.LogCallback logAct = (logString, stackTrace, type) => {
                    var lines = stackTrace.Split('\n');
                    if (2 < lines.Length)
                    {
                        var nearest = lines[1];
                        if (nearest.StartsWith(instance.ToString()))
                        {
                            logs.Add(logString);
                        }
                    }
                };

                // switch log action.
                staticLogAct = logAct;
            }
示例#5
0
 public void UnregisterThreaded(LogCallback listener)
 {
     UnityEngine.Application.logMessageReceivedThreaded -= listener;
 }
示例#6
0
 public static Delegate UnityEngine_Application_LogCallback_Self(LuaFunction func, LuaTable self)
 {
     UnityEngine.Application.LogCallback d = (new UnityEngine_Application_LogCallback_Event_Self(func, self)).Call;
     return(d);
 }
示例#7
0
        public static IEnumerator BuildAllUpdateWork(string olddir, string newdir, string diffdir, IEditorWorkProgressShower winprog)
        {
            olddir = (olddir ?? ".").TrimEnd('/', '\\');
            newdir = (newdir ?? ".").TrimEnd('/', '\\');
            diffdir = (diffdir ?? ".").TrimEnd('/', '\\');

            var logger = new EditorWorkProgressLogger() { Shower = winprog };
            System.IO.StreamWriter swlog = null;
            try
            {
                System.IO.Directory.CreateDirectory(diffdir);
                swlog = new System.IO.StreamWriter(diffdir + "/UpdateBuildLog.txt", false, System.Text.Encoding.UTF8);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log(e);
            }

            UnityEngine.Application.LogCallback LogToFile = (message, stack, logtype) =>
            {
                swlog.WriteLine(message);
                swlog.Flush();
            };
            if (swlog != null)
            {
                UnityEngine.Application.logMessageReceived += LogToFile;
            }
            bool cleanupDone = false;
            Action BuilderCleanup = () =>
            {
                if (!cleanupDone)
                {
                    logger.Log("(Phase) Build Update Cleaup.");
                    cleanupDone = true;
                    logger.Log("(Done) Build Update Cleaup.");
                    if (swlog != null)
                    {
                        UnityEngine.Application.logMessageReceived -= LogToFile;
                        swlog.Flush();
                        swlog.Dispose();
                    }
                }
            };
            if (winprog != null) winprog.OnQuit += BuilderCleanup;

            try
            {
                logger.Log("Build Res Update");
                {
                    var subdir = "/res/";
                    var oroot = olddir + subdir;
                    var nroot = newdir + subdir;
                    var droot = diffdir + subdir;
                    var nfiles = PlatDependant.GetAllFiles(nroot);
                    for (int i = 0; i < nfiles.Length; ++i)
                    {
                        var nfile = nfiles[i];
                        if (nfile.EndsWith(".zip"))
                        {
                            nfile = nfile.Substring(nroot.Length);
                            logger.Log(nfile);
                            if (BuildResUpdate(oroot + nfile, nroot + nfile, droot + nfile))
                            {
                                logger.Log("Done: " + nfile);
                            }
                            else
                            {
                                logger.Log("No diff: " + nfile);
                            }
                            if (winprog != null && AsyncWorkTimer.Check()) yield return null;
                        }
                    }
                }
                logger.Log("Build Spt Update");
                {
                    var subdir = "/spt/";
                    var oroot = olddir + subdir;
                    var nroot = newdir + subdir;
                    var droot = diffdir + subdir;
                    var nfiles = PlatDependant.GetAllFiles(nroot);
                    for (int i = 0; i < nfiles.Length; ++i)
                    {
                        var nfile = nfiles[i];
                        if (nfile.EndsWith(".zip"))
                        {
                            nfile = nfile.Substring(nroot.Length);
                            logger.Log(nfile);
                            if (BuildSptUpdate(oroot + nfile, nroot + nfile, droot + nfile))
                            {
                                logger.Log("Done: " + nfile);
                            }
                            else
                            {
                                logger.Log("No diff: " + nfile);
                            }
                            if (winprog != null && AsyncWorkTimer.Check()) yield return null;
                        }
                    }
                }
            }
            finally
            {
                BuilderCleanup();
                logger.Log("(Done) Build Update.");
            }
        }