- Home /
Question by
Beknazar-Beatz · Jun 09, 2020 at 08:55 PM ·
animationprefabprefabsconflict
how to fix this dont play animation and prefabs?,how to fix this
using UnityEngine; using System.Collections; using UnityEngine.UI; using System; using EnergySuite; using UnityEngine.SceneManagement;
public class ExampleEnegrySuite : MonoBehaviour
{
public static UiManager instance;
public Text CurrentLifeAmountText;
public Text LifeTimeLeftText;
public Slider LifeTimeLeftSlider;
public Button AddLifeButton;
public Button UseLifeButton;
public GameObject gameOverPanel;
public GameObject startUI;
public GameObject gameOverText;
public Text scoreText;
public Text highScoreText;
void OnEnable()
{
//Example
Time.timeScale = 0;
EnergySuiteManager.OnAmountChanged += OnAmountChanged;
EnergySuiteManager.OnTimeLeftChanged += OnTimeLeftChanged;
AddLifeButton.onClick.AddListener(AddLifeButtonClicked);
UseLifeButton.onClick.AddListener(UseLifeButtonClicked);
}
void OnDisable()
{
EnergySuiteManager.OnAmountChanged -= OnAmountChanged;
EnergySuiteManager.OnTimeLeftChanged -= OnTimeLeftChanged;
AddLifeButton.onClick.RemoveListener(AddLifeButtonClicked);
UseLifeButton.onClick.RemoveListener(UseLifeButtonClicked);
}
void Awake()
{
if (instance == null)
{
//instance = this;
}
}
void Start()
{
scoreText.text = ScoreManager.instance.score.ToString();
CurrentLifeAmountText.text = EnergySuiteManager.GetAmount(TimeValue.Life) + "/" + EnergySuiteManager.GetMaxAmount(TimeValue.Life);
}
public void GameStart()
{
startUI.SetActive(false);
}
public void GameOver()
{
gameOverText.SetActive(true);
highScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("HighScore");
gameOverPanel.SetActive(true);
}
public void Replay()
{
SceneManager.LoadScene("level1");
}
public void Menu()
{
SceneManager.LoadScene("Menu");
}
void AddLifeButtonClicked()
{
EnergySuiteManager.Add(TimeValue.Life, 1);
}
void UseLifeButtonClicked()
{
EnergySuiteManager.Use(TimeValue.Life, 1);
Debug.Log("Used life");
}
void OnAmountChanged(int amount, TimeBasedValue timeBasedValue)
{
string text = amount + "/" + timeBasedValue.MaxAmount;
switch (timeBasedValue.Type)
{
case TimeValue.Life:
CurrentLifeAmountText.text = text;
break;
}
}
void OnTimeLeftChanged(TimeSpan timeLeft, TimeBasedValue timeBasedValue)
{
string formatString = string.Format("{0:00}:{1:00}", timeLeft.Minutes, timeLeft.Seconds);
float sliderValue = EnergySuiteManager.ConvertToSliderValue(timeLeft, timeBasedValue);
switch (timeBasedValue.Type)
{
case TimeValue.Life:
LifeTimeLeftText.text = formatString;
LifeTimeLeftSlider.value = sliderValue;
break;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613000437im_/https://answers.unity.com/themes/thub/images/avi.jpg)