Search Unity

Basic type properties not appearing in inspector

Discussion in 'Getting Started' started by mannyvw, Jul 10, 2018.

  1. mannyvw

    mannyvw

    Joined:
    Jun 29, 2015
    Posts:
    3
    Hi

    New to unity, and this should be simple problem. Want edit the initial value of a property in a script, but can't see them in inspector.

    Its an existing code base I have updated from old unity from few years ago, entire project builds and runs so no script errors.

    Some scripts have public basic type properties (int, strings etc) but none of them are appearing in inspector however game objects appear ok, my understanding is all properties should appear ?

    This script screen shot attached is quite complicated but same happens on simple ones, game objects appear but not basic types. Am I missing something fundamental ?

    Unity Screen Shot.png

    Here is a simpler script from app, image GameObject appears in inspector but not videoFile or imageDuration

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Splash : MonoBehaviour {
    5.     public string videoFile;
    6.     public GameObject image;  
    7.     public float imageDuration = 3;
    8.  
    9.     public bool complete {
    10.         get { return (_imageTimer >= imageDuration); }
    11.     }
    12.  
    13.     private int _state = 0;
    14.     private float _imageTimer = 0;
    15.  
    16.  
    17.     protected void Start() {
    18.         if (image != null) { image.SetActive(false); }
    19.     }
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    The Inspector screen shot above suggests you're inspecting the script itself, in the Project tab, not some object using it in the Hierarchy tab.

    The script defines properties, but these properties get values when the script is actually used on some GameObject. This would be either an object in the Hierarchy, or a prefab in the Project (but even that is created by first assembling an object in the Hierarchy).
     
  3. mannyvw

    mannyvw

    Joined:
    Jun 29, 2015
    Posts:
    3
    Ah ok Thanks. Slowly wrapping my head around this Unity malarky.
     
    JoeStrout likes this.
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Don't neglect the tutorials you'll find under the Learn link at the top of this page. Most of them are really good, and will save you a ton of time figuring things out the hard way.