Why i don’t see slider?

in script I created _barSize wirh [SerializeField], but in UnityEditor in Inspector i dont see it. How i can resolution that? A day ago all was right, but today it… Before was problim with UnityEngine.UI and i regenerated project files

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
using System.IO;
using System;

public class ButtonsController : MonoBehaviour
{
[SerializeField] private GameObject _bullet;
[SerializeField] private GameObject _player;

private bool _forJump = false;
[SerializeField] private GameObject _btnJumpTrue;
[SerializeField] private GameObject _btnJumpFalse;
[SerializeField] private GameObject _btnJump;

private bool _forArrows = false;
[SerializeField] private GameObject _btnArrowsTrue;
[SerializeField] private GameObject _btnArrowsFalse;
[SerializeField] private GameObject _btnArrows;
[SerializeField] private GameObject _joy;

[SerializeField] private GameObject _btnShot;

[SerializeField] private Slider _barSize;

[SerializeField] private GameObject _settings;
[SerializeField] private GameObject _gameUI;

[SerializeField] private Reloading _rel;

private string path;

private SaveData save = new SaveData();


private void Awake()
{
#if UNITY_ANDROID && !UNITY_EDITOR
    path = Path.Combine(Application.persistentDataPath, "SaveData.json");
#else
    path = Path.Combine(Application.dataPath, "SaveData.json");
#endif
    save = JsonUtility.FromJson<SaveData>(File.ReadAllText(path));

    if (File.Exists(path))
    {
        LoadGame();
    }
    else
    {
        SaveGame();
    }
    
}
private void Start()
{

    BtnForJump();
    BtnForArrows();
}

public void Restart()
{
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    File.WriteAllText(path, JsonUtility.ToJson(save));
}

public void BtnForJump()
{

    _forJump = !_forJump;
    
    if (_forJump == true)
    {
        _btnJump.SetActive(true);
        _btnJumpTrue.SetActive(true);
        _btnJumpFalse.SetActive(false);
    }
    else if (_forJump == false)
    {
        _btnJump.SetActive(false);
        _btnJumpTrue.SetActive(false);
        _btnJumpFalse.SetActive(true);
    }
}

public void BtnForArrows()
{

    _forArrows = !_forArrows;
    if (_forArrows == true)
    {
        _joy.SetActive(false);
        _btnArrows.SetActive(true);
        _btnArrowsTrue.SetActive(true);
        _btnArrowsFalse.SetActive(false);

        _btnJump.SetActive(true);
        _btnJumpTrue.SetActive(true);
        _btnJumpFalse.SetActive(false);
        _forJump = !_forJump;
        
    }
    else if (_forArrows == false)
    {
        _joy.SetActive(true);
        _btnArrows.SetActive(false);
        _btnArrowsTrue.SetActive(false);
        _btnArrowsFalse.SetActive(true);
    }

}

public void Shoot()
{
    
    if (_rel.isReloaded)
    {
        Instantiate(_bullet, _player.transform.position, _player.transform.rotation);
        _rel.isReloaded = false;
        _rel._currentTimeReload = _rel._timeReloading;
        _rel.timerVisual.SetActive(true);
    }
    
}

public void Settings()
{
    if (_settings.activeInHierarchy == false)
    {
        _gameUI.SetActive(false);
        _settings.SetActive(true);
        Time.timeScale = 0;
    }
        
    else
    {
        ExitFromSetPosition();
        _gameUI.SetActive(true);
        _settings.SetActive(false);
        Time.timeScale = 1;
        
    }
}

public void Exit()
{
    Application.Quit();
}

public void PlaySingle()
{
    SceneManager.LoadScene("Singleplay");
}

public void ToMainMenu()
{
    SceneManager.LoadScene("MainMenu");
}

public void SetPosition()
{
    _settings.SetActive(false);
    _gameUI.SetActive(true);
    _btnJump.GetComponent<BoxCollider2D>().enabled = true;
    _btnArrows.GetComponent<BoxCollider2D>().enabled = true;
    _joy.GetComponent<BoxCollider2D>().enabled = true;
    _btnShot.GetComponent<BoxCollider2D>().enabled = true;
}

public void ExitFromSetPosition()
{
    _settings.SetActive(true);
    _gameUI.SetActive(false);
    _btnJump.GetComponent<BoxCollider2D>().enabled = false;
    _btnArrows.GetComponent<BoxCollider2D>().enabled = false;
    _joy.GetComponent<BoxCollider2D>().enabled = false;
    _btnShot.GetComponent<BoxCollider2D>().enabled = false;
    SaveGame();

}

private void SaveGame()
{
    save.arrows = _forArrows;
    save.jump = _forJump;

    save.sizeJoystick = _joy.transform.localScale;
    save.sizeArrows = _btnArrows.transform.localScale;
    save.sizeJump = _btnJump.transform.localScale;
    save.sizeShot = _btnShot.transform.localScale;

    save.posJoystick = Camera.main.ScreenToWorldPoint(new Vector3(_joy.transform.position.x, _joy.transform.position.y, 0));
    save.posArrows = Camera.main.ScreenToWorldPoint(new Vector3(_btnArrows.transform.position.x, _btnArrows.transform.position.y, 0));
    save.posJump = Camera.main.ScreenToWorldPoint(new Vector3(_btnJump.transform.position.x, _btnJump.transform.position.y, 0));
    save.posShot = Camera.main.ScreenToWorldPoint(new Vector3(_btnShot.transform.position.x, _btnShot.transform.position.y, 0));

    Debug.Log("Game data saved!");
}

private void LoadGame()
{
    _forArrows = !save.arrows;
    _forJump = !save.jump;

    _joy.transform.localScale = save.sizeJoystick;
    _btnArrows.transform.localScale = save.sizeArrows;
    _btnJump.transform.localScale = save.sizeJump;
    _btnShot.transform.localScale = save.sizeShot;

    _joy.transform.position = save.posJoystick;
    _btnArrows.transform.position = save.posArrows;
    _btnJump.transform.position = save.posJump;
    _btnShot.transform.position = save.posShot;
}
}
[Serializable]
class SaveData
{
public Vector3 sizeJoystick;
public Vector3 sizeArrows;
public Vector3 sizeJump;
public Vector3 sizeShot;

public Vector2 posJoystick;
public Vector2 posArrows;
public Vector2 posJump;
public Vector2 posShot;

public bool jump;
public bool arrows;
}

If u will help me i will very very happy. I NEED MORE WOERDSSSSSSSSSSSSSSSSS

Leave a Comment