예제 #1
0
    void UpdateLog()
    {
        int    logMessageCount = RecastNavigationDllImports.GetGwNavLogMessageCount();
        int    msgSize         = 0;
        string fullLog         = "";

        for (int msgIdx = 0; msgIdx < logMessageCount; ++msgIdx)
        {
            IntPtr logMsgPtr = RecastNavigationDllImports.GetGwNavLog(msgIdx, out msgSize);
            if (msgSize != 0)
            {
                string logMsg = Marshal.PtrToStringAnsi(logMsgPtr);

                if (logMsg != null && logMsg.Length != 0)
                {
                    fullLog += logMsg;
                    if (logMsg.EndsWith("\n"))
                    {
                        fullLog.Remove(fullLog.Length - 1);
                        Debug.Log("[RecastNavigation] " + fullLog);
                        fullLog = "";
                    }
                }
            }
        }

        // No need to flush if no message (save a call to the plugin)
        if (logMessageCount > 0)
        {
            RecastNavigationDllImports.FlushGwNavLog();
        }
    }
예제 #2
0
    void UpdateLog_AllMessagesInOneUnityLog()
    {
        int logMessageCount = RecastNavigationDllImports.GetGwNavLogMessageCount();
        int msgSize         = 0;

        if (logMessageCount == 0)
        {
            return;
        }

        string fullLog = "";

        for (int msgIdx = 0; msgIdx < logMessageCount; ++msgIdx)
        {
            IntPtr logMsgPtr = RecastNavigationDllImports.GetGwNavLog(msgIdx, out msgSize);
            if (msgSize != 0)
            {
                string logMsg = Marshal.PtrToStringAnsi(logMsgPtr);

                // Hide the ========
                if (logMsg.StartsWith("="))
                {
                    continue;
                }

                // Dont jump 2 lines, only one
                if (logMsg.StartsWith("\n\n"))
                {
                    fullLog += '\n';
                    continue;
                }

                if (logMsg != null && logMsg.Length != 0)
                {
                    fullLog += logMsg;
                }
            }
        }

        if (fullLog.Length != 0)
        {
            Debug.Log("[RecastNavigation] " + fullLog);
        }

        RecastNavigationDllImports.FlushGwNavLog();
    }