Enabling and Disabling Components

EnableComponents using UnityEngine; using System.Collections; public class EnableComponents : MonoBehaviour { private Light myLight; void Start () { myLight = GetComponent<Light>(); } void Update () { if(Input.GetKeyUp(KeyCode.Space)) { myLight.enabled = !myLight.enabled; } } } What I Learned In this task I learned how to enable and disable unity components via script and or Unity Editor.

UpdateAndFixedUpdate

UpdateAndFixedUpdate using UnityEngine; using System.Collections; public class UpdateAndFixedUpdate : MonoBehaviour { void FixedUpdate () { Debug.Log(“FixedUpdate time :” + Time.deltaTime); } void Update () { Debug.Log(“Update time :” + Time.deltaTime); } } What I Learned  

Awake and Start

AwakeAndStart using UnityEngine; using System.Collections; public class AwakeAndStart : MonoBehaviour { void Awake () { Debug.Log(“Awake called.”); } void Start () { Debug.Log(“Start called.”); } } What I Learned Awakes are references between scripts and initialization. Start is called after awake. Start is started once script component is enabled. Awake function can then be used…

Read more Awake and Start

Scope and Access Modifiers

Scope and Access Modifiers using UnityEngine; using System.Collections; public class ScopeAndAccessModifiers : MonoBehaviour { public int alpha = 5; private int beta = 0; private int gamma = 5; private AnotherClass myOtherClass; void Start () { alpha = 29; myOtherClass = new AnotherClass(); myOtherClass.FruitMachine(alpha, myOtherClass.apples); } void Example (int pens, int crayons) { int answer;…

Read more Scope and Access Modifiers

Activating Game Objects

Active Objects using UnityEngine; using System.Collections; public class ActiveObjects : MonoBehaviour { void Start () { gameObject.SetActive(false); } } What I Learned In this task, I learned how to reference GameObjects in code and set their values. I also learned how to have GameObjects connect to certain presets within the code. Resources: