Professional Documents
Culture Documents
void Update ()
{ 12. 12. Update and FixedUpdate
Debug.Log("Alpha is set to: " + alpha);
}
}
using UnityEngine;
private void OfficeSort (int a, int b) using System.Collections;
{
int answer; public class EnableComponents : MonoBehaviour
answer = a + b; {
Debug.Log("Office Supplies total: " + answer); private Light myLight;
}
}
void Start ()
{
11. 11. Awake and Start myLight = GetComponent<Light>();
}
using UnityEngine;
using System.Collections; void Update ()
{
public class AwakeAndStart : MonoBehaviour if(Input.GetKeyUp(KeyCode.Space))
{ {
void Awake () myLight.enabled = !myLight.enabled;
{ }
Debug.Log("Awake called."); }
} }
using UnityEngine;
using System.Collections;
void Start()
21. Singleton – scene manager
{ using UnityEngine;
graphic.sprite = standard; using UnityEngine.SceneManagement;
} using UnityEngine.UI;
void Update()
{ public class SceneManagerScript : MonoBehaviour
bool down = Input.GetButtonDown("Jump"); {
bool held = Input.GetButton("Jump"); public Text ValueTxt;
bool up = Input.GetButtonUp("Jump"); private void Start()
{
if(down) ValueTxt.text = PersistentManagerScript.Instance.Value.ToString();
{ }
graphic.sprite = downgfx; public void GoToFirstScene()
} {
else if (held) SceneManager.LoadScene("first");
{ PersistentManagerScript.Instance.Value++;
graphic.sprite = heldgfx; }
} public void GoToSecondScene()
else if (up) {
{ SceneManager.LoadScene("second");
graphic.sprite = upgfx; PersistentManagerScript.Instance.Value++;
}
else }
{
graphic.sprite = standard; }
}
27. BallSizeControl
using UnityEngine;
using UnityEngine.UI;
public class BallSizeControl : MonoBehaviour
{
public Slider sizeSlider;
public float minSize = 1.0f;
public float maxSize = 5.0f;
private void Start()
{
sizeSlider.onValueChanged.AddListener(ChangeBallSize);
}
private void ChangeBallSize(float value)
{
float newSize = Mathf.Lerp(minSize, maxSize, value);
transform.localScale = new Vector3(newSize, newSize, newSize);
}
}
27. Scroll Texture Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SrollTex: monoBehaviour
{
public float ScrollX = 0.5f;
public float ScrollY = 0.5f;
void update()
{
float offsetX = Time.time * __________;
float offsetY = Time.time * __________;
GetComponent<Renderer>().material.mainTextureOffset = new Vector2(___________,
_________________);
}
}