Search Unity

Why when I change some values of propertie in the inspector of my script it's highlightnig the text?

Discussion in 'Scripting' started by Chocolade, Jul 31, 2018.

  1. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    A simple script that attached to a GameObject in the Hierarchy:

    First the variable in the editor in the inspector of the script Speed Change Wait was highlighted I mean it's much black painted then the rest.

    Then when I changed or changing other variables values in the editor in the inspector they are also become more black painted.
    In the screenshot the Headers like Door Init or Door Moves should be in black and painted more then the rest. But now also the other variables like this. I can't figure out why.

    For example Random Speed Range is not yet in highlighted black but once I will change it's value it will too.



    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. public class GateControl : MonoBehaviour
    6. {
    7.  [Header("Door Init")]
    8.  [Space(5)]
    9.  public Transform door;
    10.  [Header("Door Moves")]
    11.  [Space(5)]
    12.  public float doorMovingLength = 64f;
    13.  [Header("Door Speed")]
    14.  [Space(5)]
    15.  public float constantDoorSpeed = 1f;
    16.  public float currentDoorSpeed;
    17.  [Header("Door Random")]
    18.  [Space(5)]
    19.  public bool randomDoorSpeed = false;
    20.  public int speedChangeWait = 7;
    21.  [Range(0.3f, 10)]
    22.  public float randomSpeedRange;
    23.  private Vector3 originalDoorPosition;
    24.  private bool isRising = true;
    25.  private float fraq = 0;
    26.  private float timer = 0;
    27.  // Use this for initialization
    28.  void Start()
    29.  {
    30.   originalDoorPosition = door.position;
    31.   StartCoroutine(DoorSpeedWaitForSeconds());
    32.  }
    33.  // Update is called once per frame
    34.  void Update()
    35.  {
    36.   if (isRising)
    37.    fraq += Time.deltaTime * currentDoorSpeed;
    38.   else
    39.    fraq -= Time.deltaTime * currentDoorSpeed;
    40.   if (fraq >= 1)
    41.    isRising = false;
    42.   if (fraq <= 0)
    43.    isRising = true;
    44.   fraq = Mathf.Clamp(fraq, 0, 1);
    45.   door.position = Vector3.Lerp(originalDoorPosition,
    46.    new Vector3(originalDoorPosition.x, originalDoorPosition.y, doorMovingLength),
    47.    fraq);
    48.  }
    49.  IEnumerator DoorSpeedWaitForSeconds()
    50.  {
    51.   timer = 0;
    52.   while (true)
    53.   {
    54.    if (randomDoorSpeed == true && randomSpeedRange > 0.3f)
    55.     currentDoorSpeed = Random.Range(0.3f, randomSpeedRange);
    56.    if (!randomDoorSpeed)
    57.     currentDoorSpeed = constantDoorSpeed;//reset back to original value
    58.    while (timer < speedChangeWait) { timer += Time.deltaTime; yield return null; }
    59.    timer = 0;
    60.   }
    61.  }
    62.     #if UNITY_EDITOR // make OnValidate() only exist in Editor mode
    63.  private void OnValidate()
    64.  {
    65.   timer = 0;
    66.  }
    67.     #endif
    68. }
    69.  
     
  2. LOGames

    LOGames

    Joined:
    Sep 4, 2016
    Posts:
    19
    That bold text is just to let you know that a value has been edited in the inspector and isn't using its scripted default value anymore. If you were to right click and 'Reset' ( think that's the option name) it would return to the default and become unbolded.
     
    Chocolade likes this.
  3. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    I understand now. But then what meaning there is for the Headers attributes ? If the headers and the properties inside both bold ?