コード例 #1
0
ファイル: Logger.cs プロジェクト: nNnCoder/Instech
        /// <summary>
        /// 输出日志
        /// </summary>
        /// <param name="module">日志所属模块</param>
        /// <param name="level">日志等级</param>
        /// <param name="message">日志信息</param>
        /// <param name="context">上下文信息</param>
        /// <param name="ex">异常信息</param>
        private static void Log(string module, LogLevel level, string message, Object context, Exception ex = null)
        {
            if (level > LogLevel)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(message) && level != LogLevel.Exception)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(module))
            {
                module = "Default";
            }
            var stackTrace = new StackTrace(true);

            if (level == LogLevel.Exception && ex != null)
            {
                var exMessage = new StringBuilder();
                exMessage.Append("[!]异常信息: ");
                exMessage.Append(ex.Message);
                exMessage.Append('\n');
                exMessage.Append("[!]异常类型: ");
                exMessage.Append(ex.GetType());
                exMessage.Append('\n');
                exMessage.Append("[!]调用栈:\n ");
                exMessage.Append(ex.StackTrace);
                exMessage.Append("\n=============");
                OnLog?.Invoke(module, exMessage.ToString(), LogLevel.Exception, stackTrace);
                Debug.LogException(ex, context);
                Debug.Log(exMessage, context);
                return;
            }
            OnLog?.Invoke(module, message, level, stackTrace);
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                var msg = $"[{level}][{module}] - {message}";
                switch (level)
                {
                case LogLevel.Assert:
                    Debug.LogAssertion(msg, context);
                    break;

                case LogLevel.Exception:
                case LogLevel.Error:
                    Debug.LogError(msg, context);
                    break;

                case LogLevel.Warning:
                    Debug.LogWarning(msg, context);
                    break;

                case LogLevel.Info:
                case LogLevel.Debug:
                    Debug.Log(msg, context);
                    break;
                }
            }
        }
コード例 #2
0
 void OnClickBtn2()
 {
     Debug.Log("test  log");
     Debug.LogWarning("test  log warn");
     Debug.LogError("test  log error");
     Debug.LogAssertion("test  log assert");
     //test exception
     text1.text = "text";
 }
コード例 #3
0
        public T Get <T>(string name) where T : Object
        {
            if (!AssetsDict.ContainsKey(name))
            {
                Debug.LogAssertion("Cant get an asset with name=" + name);
                return(default(T));
            }

            return((T)AssetsDict[name]);
        }
コード例 #4
0
ファイル: Target.cs プロジェクト: RTUITLab/RevolIT
 public void Respawn()
 {
     if (_cameraEffect != null)
     {
         _cameraEffect.RespawnEffect();
         vRRig.EnableForward();
     }
     else
     {
         Debug.LogAssertion($"47. Target -> _cameraEffect is null");
     }
 }
コード例 #5
0
        private void AssertionFailure(string userMessage)
        {
            if (Debugger.IsAttached)
            {
                throw new AssertionException("AnimationPlayer Assertion Failure", userMessage);
            }
            if (Assert.raiseExceptions)
            {
                throw new AssertionException("AnimationPlayer Assertion Failure", userMessage);
            }

            Debug.LogAssertion(userMessage);
        }
コード例 #6
0
        public static void LogAssertion(Author author, object message, Object context = null)
        {
            if (!Pass(author, LogType.Log))
            {
                return;
            }

            if (Convert.IsDBNull(context))
            {
                Debug.LogAssertion(Format(author, message));
            }
            else
            {
                Debug.LogAssertion(Format(author, message), context);
            }
        }
コード例 #7
0
ファイル: BuildsShortcuts.cs プロジェクト: sebizart/TDShow
    public static void OpenLastBuildDirectory()
    {
        // Creates the builds folder if it does not already exists
        CreateDirectory(buildsFolder);

        // Get all builds folder
        string[] _buildFolders = Directory.GetDirectories(buildsFolder);

        // If at least one folder is found, open the last edited one
        if (_buildFolders != null && _buildFolders.Length > 0)
        {
            Process.Start(_buildFolders.OrderBy(f => Directory.GetLastWriteTime(f)).Last());
        }
        // If there's no folder, debug it
        else
        {
            Debug.LogAssertion("There is no build in the default build folder !");
        }
    }
コード例 #8
0
ファイル: Target.cs プロジェクト: RTUITLab/RevolIT
 void Die()
 {
     isDied = true;
     if (coltDetach != null)
     {
         coltDetach();
     }
     else
     {
         Debug.LogAssertion($" Target -> _colt  is null");
     }
     if (_cameraEffect != null)
     {
         _cameraEffect.DieEffect();
         StartCoroutine(TimerForEnableDieText());
         // disable rigging
         vRRig.DisableForward();
         // detach colt
     }
     else
     {
         Debug.LogAssertion($"Target -> coltDetach is null, maybe player don't have colt in hands?");
     }
 }
コード例 #9
0
ファイル: BuildsShortcuts.cs プロジェクト: sebizart/TDShow
    public static void LaunchLastBuild()
    {
        // Creates the builds folder if it does not already exists
        CreateDirectory(buildsFolder);

        // Get all builds folder
        string[] _buildFolders = Directory.GetDirectories(buildsFolder);

        // If at least one folder is found, try to find the .exe file in the last edited one
        if (_buildFolders != null && _buildFolders.Length > 0)
        {
            // Get the last edited folder
            string _buildFolder = _buildFolders.OrderBy(f => Directory.GetLastWriteTime(f)).Last();

            // Get the .exe file path
            string _exeFilePath = _buildFolder + '/' + Application.productName + ".exe";

            // If the .exe file exists, launch it
            if (File.Exists(_exeFilePath))
            {
                Process.Start(_exeFilePath);
            }
            // If it does not exist, debug it and open the build directory
            else
            {
                Debug.LogAssertion("There is no .exe file in the last build folder or it has a different name !");

                Process.Start(_buildFolder);
            }
        }
        // If there's no folder, debug it
        else
        {
            Debug.LogAssertion("There is no build in the default build folder !");
        }
    }
コード例 #10
0
 public static void LogAssertion(object message, UnityObject context)
 {
     UnityDebug.LogAssertion(message, context);
 }
コード例 #11
0
 public static void LogAssertion(object message)
 {
     UnityDebug.LogAssertion(message);
 }
コード例 #12
0
        private void executeDebug(string[] args)
        {
            if (args.Length == 0)
            {
                Debug.Log("");
            }
            else
            {
                string message = string.Join(" ", args, 1, args.Length - 1);
                switch (args[0])
                {
                case "-a":
                    Debug.LogAssertion(message, this);
                    break;

                case "-e":
                    Debug.LogError(message, this);
                    break;

                case "-x":
                    Debug.LogException(new Exception(message), this);
                    break;

                case "-l":
                    Debug.Log(message, this);
                    break;

                case "-w":
                    Debug.LogWarning(message, this);
                    break;

                case "-B":
                    Debug.Break();
                    break;

                case "-V":
                    Debug.Log(Debug.developerConsoleVisible);
                    break;

                case "-C":
                    Debug.ClearDeveloperConsole();
                    break;

                case "-D":
                    Debug.Log(Debug.isDebugBuild);
                    break;

                case "-H":
                    if (args.Length == 1)
                    {
                        Debug.Log(_hideDevConsole);
                    }
                    else if (args.Length == 2)
                    {
                        bool hideDevConsole = Utils.BoolParse(args[1]);
                        _hideDevConsole = hideDevConsole;
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-L":
                    if (args.Length == 3)
                    {
                        if (Utils.TryParseVector3(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 start) &&
                            Utils.TryParseVector3(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 end)
                            )
                        {
                            Debug.DrawLine(start, end, Color.black, 10f, false);
                        }
                        else
                        {
                            Debug.LogError("cannot parse \'" + args[1] + "\' to Vector3");
                        }
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-R":
                    if (args.Length == 3)
                    {
                        if (Utils.TryParseVector3(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 start) &&
                            Utils.TryParseVector3(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out Vector3 dir)
                            )
                        {
                            Debug.DrawRay(start, dir, Color.black, 10f, false);
                        }
                        else
                        {
                            Debug.LogError("cannot parse \'" + args[1] + "\' to Vector3");
                        }
                    }
                    else
                    {
                        throw new SyntaxException();
                    }
                    break;

                case "-G":
                    int   size      = 64;
                    Color color     = Color.grey;
                    float duration  = 10f;
                    bool  depthTest = false;
                    for (int i = 1 - size; i < size; i++)
                    {
                        Debug.DrawLine(new Vector3(-size, 0f, i), new Vector3(size, 0f, i), color, duration, depthTest);
                        Debug.DrawLine(new Vector3(i, 0f, -size), new Vector3(i, 0f, size), color, duration, depthTest);
                    }
                    break;

                default:
                    Debug.Log(string.Join(" ", args, 0, args.Length));
                    break;
                }
            }
        }
コード例 #13
0
        public void FillHeightMapNoise(int xStart, int yStart, float[,] heights)
        {
            Debug.Log($"FillHeightMapNoise({xStart}, {yStart}) on thread {Thread.CurrentThread.ManagedThreadId}");
            int mapWidth  = heights.GetUpperBound(1) + 1;
            int mapHeight = heights.GetUpperBound(0) + 1;

            HeightNoise.GetNoise().GetNoiseSet(xStart, yStart, ref heights, true);
            float min           = float.PositiveInfinity;
            float max           = float.NegativeInfinity;
            float currentHeight = 0;

            for (int x = 0; x < mapWidth; x++)
            {
                for (int y = 0; y < mapHeight; y++)
                {
                    if (TrueNormalize || ShowRange)
                    {
                        currentHeight = heights[y, x];
                        min           = Mathf.Min(min, currentHeight);
                        max           = Mathf.Max(max, currentHeight);
                    }
                }
            }

            HeightMax = Mathf.Max(HeightMax, max);
            HeightMin = Mathf.Min(HeightMin, min);

            float normalizationMultiplier = TrueNormalize ? 1.0f / (max - min) : 1.0f / (TransformMax - TransformMin);

            Debug.Log($"TransformMin: {TransformMin}");
            Debug.Log($"normalizationMultiplier: {normalizationMultiplier}");

            for (int x = 0; x < mapWidth; x++)
            {
                for (int y = 0; y < mapHeight; y++)
                {
                    currentHeight = heights[y, x];

                    if (TrueNormalize)
                    {
                        // normalize
                        currentHeight -= min;
                        currentHeight *= normalizationMultiplier;
                    }
                    else
                    {
                        // approximate normalization with preset values
                        currentHeight -= TransformMin;
                        currentHeight *= normalizationMultiplier;
                    }

                    // exponentiate to exaggerate high terrain and flatten low terrain
                    //current = Mathf.Pow(current, Exponent);
                    currentHeight = HeightAdjustCurve.Evaluate(currentHeight);

                    heights[y, x] = currentHeight;
                }
            }

            if (!TrueNormalize && ShowRange)
            {
                if ((max - TransformMin) * normalizationMultiplier > 1.0f)
                {
                    Debug.LogAssertion("max value exceeded 1.0");
                }
                if ((min - TransformMin) * normalizationMultiplier < 0f)
                {
                    Debug.LogAssertion("min value below 0");
                }
                //Debug.Log($"min before normalization: {min}");
                //Debug.Log($"max before normalization: {max}");
            }
        }