Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Problem printing color info

Discussion in 'Scripting' started by bobueland, May 19, 2020.

  1. bobueland

    bobueland

    Joined:
    Sep 27, 2019
    Posts:
    19
    Screen Shot 2020-05-19 at 6.57.44 AM.png
    When using random color I get all three lines printed


    blackColor.png
    When using a color that does not change I get only one line printed instead of three


    I have problems printing color info when the color does not change. Here is my code

    Code (CSharp):
    1. Color color;
    2.  
    3.     void Start()
    4.     {
    5.  
    6.         for (int i = 0; i < 3; i++)
    7.         {
    8.             color = randomColor();
    9.             //color = new Color(0f, 0f, 255f);
    10.             print(color);
    11.         }
    12.     }
    13.  
    14.     Color randomColor()
    15.     {
    16.         return new Color(
    17.          (float)Random.Range(0, 255),
    18.          (float)Random.Range(0, 255),
    19.          (float)Random.Range(0, 255)
    20.      );
    21.     }
    When I use
    color = randomColor();
    I get three lines printed.
    But when I comment that line out and uncomment
    color = new Color(0f, 0f, 255f);
    then I only get one line printed, although I loop three times.

    Is the problem only on my machine or is this deliberately done by Unity. And if so why. Very confusing.
     
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Its grouping your messages. Notice the little numberon the far right of your console log it says how many times that mesaage appeared. One of the options is to group error messages, untick that and youll be fine. Think its called collapse
     
    bobueland likes this.
  3. bobueland

    bobueland

    Joined:
    Sep 27, 2019
    Posts:
    19