1
\$\begingroup\$

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.

Inspector

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GateControl : MonoBehaviour
{
    [Header("Door Init")]
    [Space(5)]

    public Transform door;

    [Header("Door Moves")]
    [Space(5)]

    public float doorMovingLength = 64f;

    [Header("Door Speed")]
    [Space(5)]

    public float constantDoorSpeed = 1f;
    public float currentDoorSpeed;

    [Header("Door Random")]
    [Space(5)]

    public bool randomDoorSpeed = false;
    public int speedChangeWait = 7;
    [Range(0.3f, 10)]
    public float randomSpeedRange;

    private Vector3 originalDoorPosition;
    private bool isRising = true;
    private float fraq = 0;
    private float timer = 0;

    // Use this for initialization
    void Start()
    {
        originalDoorPosition = door.position;
        StartCoroutine(DoorSpeedWaitForSeconds());
    }

    // Update is called once per frame
    void Update()
    {
        if (isRising)
            fraq += Time.deltaTime * currentDoorSpeed;
        else
            fraq -= Time.deltaTime * currentDoorSpeed;

        if (fraq >= 1)
            isRising = false;
        if (fraq <= 0)
            isRising = true;

        fraq = Mathf.Clamp(fraq, 0, 1);

        door.position = Vector3.Lerp(originalDoorPosition,
            new Vector3(originalDoorPosition.x, originalDoorPosition.y, doorMovingLength),
            fraq);
    }

    IEnumerator DoorSpeedWaitForSeconds()
    {
        timer = 0;

        while (true)
        {
            if (randomDoorSpeed == true && randomSpeedRange > 0.3f)
                currentDoorSpeed = Random.Range(0.3f, randomSpeedRange);

            if (!randomDoorSpeed)
                currentDoorSpeed = constantDoorSpeed;//reset back to original value

            while (timer < speedChangeWait) { timer += Time.deltaTime; yield return null; }
            timer = 0;
        }
    }

    #if UNITY_EDITOR // make OnValidate() only exist in Editor mode
    private void OnValidate()
    {
        timer = 0;
    }
    #endif
}
\$\endgroup\$
3
\$\begingroup\$

The hightlight indicates that the values are not the default values of the prefab but are specific to this instance. If you want to apply these changes to your prefab you can press "Appply" on the top of the editor and the values will no longer be highlighted since they became the default value of the prefab.

You can read this sentence in the Prefab Documentation :

To make it clear when a property has been overridden, it is shown in the inspector with its name label in boldface.

\$\endgroup\$
  • \$\begingroup\$ I understand it now. But then what meaning there is for the headers attributes if they are also bolded like the properties ? At least in my logic it wasn't suppose to get bold when changing the value of a variable in the inspector if you are using headers.Or at least the headers should be in other color/s then bold black. \$\endgroup\$ – Benzi Avrumi Jul 31 '18 at 15:55
  • 1
    \$\begingroup\$ @BenziAvrumi that sounds like a UI styling question to ask the Unity developers who chose boldface black for the headers. It might have no better answer than "we liked the way it looked" though. ;) \$\endgroup\$ – DMGregory Jul 31 '18 at 18:46
0
\$\begingroup\$

The highlight indicates that that value is not at it's default value.

As I recall there's a right click option to reset it to the default value. It is purely there as a visual aid.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.