Search Unity

Question Public class not showing in inspector.

Discussion in 'Scripting' started by mlgsnoops, Jun 24, 2020.

  1. mlgsnoops

    mlgsnoops

    Joined:
    Jun 6, 2020
    Posts:
    18
    This line is not showing up
    public Slider reality, soul, mind, time, space, power;


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UIElements;
    5.  
    6. public class SliderController1 : MonoBehaviour
    7. {
    8.     public Light sun;
    9.     public GameObject particle;
    10.     private ParticleSystem particles;
    11.    
    12.     public Slider reality, soul, mind, time, space, power;
    13.     ParticleSystem.MainModule psMain;
    14.     ParticleSystem.EmissionModule psEmit;
    15.     ParticleSystem.LightsModule psLight;
    16.  
    17.    
    18.     // Start is called before the first frame update
    19.     void Start()
    20.     {
    21.         particles = particle.GetComponent<ParticleSystem>();
    22.         psMain = particles.main;
    23.         psEmit = particles.emission;
    24.         psLight = particles.lights;
    25.     }
    26.  
    27.  
    28.  
    29.  
    30.     // Update is called once per frame
    31.     void Update()
    32.     {
    33.        
    34.     }
    35.     void particlePlay1 (){
    36.         particle.SetActive (true);
    37.         psMain.startColor = new Color (0.965f, 0.549f, 0.125f, 1);
    38.     }
    39. }
    40.  
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Do you have any compile errors?
     
  3. mlgsnoops

    mlgsnoops

    Joined:
    Jun 6, 2020
    Posts:
    18
    i have no errors
     
  4. mlgsnoops

    mlgsnoops

    Joined:
    Jun 6, 2020
    Posts:
    18
    no
     
  5. psykick1

    psykick1

    Joined:
    May 19, 2020
    Posts:
    61
    You attached the script to the GameObject ? o_O
     
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    You're not importing UnityEngine.UI, so the only way you can reference "Slider" is if you made your own class named Slider. Since that's not serializable, it's not showing up.

    So you want to either:
    - Remove/rename your own slider type and import UnityEngine.UI in that file
    - Reference UnityEngine.UI.Slider instead of "Slider"

    ... wait, so you're referencing UnityEngine.UIElements. It might be that UI Elements has it's own Slider? In that case you'd be good by just replacing that import with an import of UnityEngine.UI.
     
    alifdadali and StarManta like this.
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Oh, good catch with UIElements. Yeah, UnityEngine.UIElements is not UnityEngine.UI and the two classes don't have anything to do with each other. Definitely needs to be UnityEngine.UI instead.