summaryrefslogtreecommitdiffhomepage
path: root/Assets/Scripts/ScaleSlider.cs
blob: 69bb58fb7c6001464bcbfca376ed86839df5804b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class ScaleSlider : MonoBehaviour
{
	public Slider slider;
	private Graph graph;
	private TMP_Text text; 

	void Awake()
	{
		var gameObjectGraph = GameObject.Find("Graph");
		graph = gameObjectGraph.GetComponent<Graph>();
		var gameObjectText = GameObject.Find("ScaleText");
		text = gameObjectText.GetComponent<TMP_Text>();
		slider.onValueChanged.AddListener((value) => {
				graph.SetFunctionScale((float)value);
				text.text = "Function Scale: " + value.ToString("0.0");
				});
	}
}