Question by
patrickharvey · Dec 10, 2017 at 04:26 PM ·
scripting problemscripting beginnerscriptingbasicsint
how to change the value of my slider(in the inspector) thanks
because in the script that i wrote it has a fix value and i want my slider to become changeable. sorry for my english grammar i hope you will understand me. someone can help me please?
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class MeterManager : MonoBehaviour
{
public Button[] buttons;
bool GameOver;
int meter;
public Slider meterSlider;
public uimanager ui;
public GameObject MC, Text, Ok;
private carcontroller car;
// Use this for initialization
void Start()
{
MC.SetActive (false);
Text.SetActive (false);
Ok.SetActive (false);
car = FindObjectOfType<carcontroller> ();
GameOver = false;
meter = 0;
InvokeRepeating("meterUpdate", 1f, 1f);
}
// Update is called once per frame
void Update()
{
meterSlider.value = meter;
if (meterSlider.value >= 10)
{
gamecontroller.MoneyAmount = 120;
Destroy (car);
Time.timeScale = 0;
MC.SetActive (true);
Text.SetActive (true);
Ok.SetActive (true);
}
}
void meterUpdate()
{
if (GameOver == false)
{
meter += 1;
}
}
public void Gamestart() {
GameOver = true;
foreach(Button button in buttons) {
button.gameObject.SetActive(true);
}
}
}
Comment
After selecting the Slider, change the 'Value' in inspector.
Your answer
Follow this Question
Related Questions
Make enemy patrol without Nav Points? 0 Answers
Timer wont work 0 Answers
Getting weird error message!?!?!? 1 Answer
random spawn enemy problem 0 Answers
tagged objects problem 0 Answers