Professional Documents
Culture Documents
44444
44444
void Update ()
void Start () {
{ if(Input.GetKeyUp(KeyCode.Space))
Debug.Log("Start called."); {
} myLight.enabled = !myLight.enabled;
} }
}
}
12. 12. Update and FixedUpdate
14. ActiveObjects
using UnityEngine;
using UnityEngine; using System.Collections;
using System.Collections;
public class ActiveObjects : MonoBehaviour
public class UpdateAndFixedUpdate : MonoBehaviour {
{ void Start ()
void FixedUpdate () {
{ gameObject.SetActive(false);
Debug.Log("FixedUpdate time :" + Time.deltaTime); }
} }
15. CheckState
using UnityEngine;
void Update () using System.Collections;
{
Debug.Log("Update time :" + Time.deltaTime); public class CheckState : MonoBehaviour
} {
} public GameObject myObject;
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);
}
}