DemoScript C#
using UnityEngine;using System.Collections;
public class DemoScript : MonoBehaviour {
public Light myLight;
void Update () {
if (Input.GetKey ("space")) {
myLight.enabled = true;
} else {
myLight.enabled = false;
}
}
}
-------------------
using UnityEngine;
using System.Collections;
public class DemoScript : MonoBehaviour {
public Light myLight;
void Update () {
if (Input.GetKeyDown ("space")) {
myLight.enabled = true;
}
if (Input.GetKeyUp ("space")) {
myLight.enabled = false;
}
}
}
----------------
using UnityEngine;
using System.Collections;
public class DemoScript : MonoBehaviour {
public Light myLight;
void Update () {
if (Input.GetKeyDown ("space")) {
myLight.enabled = !myLight.enabled;
}
}
}
------------------
using UnityEngine;
using System.Collections;
public class DemoScript : MonoBehaviour {
public Light myLight;
void Awake () {
int myVar = AddTwo(9,2);
Debug.Log(myVar);
}
void Update () {
if (Input.GetKeyDown ("space")) {
MyFunction ();
}
}
void MyFunction () {
myLight.enabled = !myLight.enabled;
}
string AddTwo (int var1, int var2) {
int returnValue = var1 + var2;
return returnValue;
}
}
------------------
using UnityEngine;
using System.Collections;
[System.Serializable]
public class DataClass {
public int myInt;
public float myFloat;
}
public class DemoScript : MonoBehaviour {
public Light myLight;
public DataClass[] myClass;
void Awake () {
int myVar = AddTwo(9,2);
Debug.Log(myVar);
}
void Update () {
if (Input.GetKeyDown ("space")) {
MyFunction ();
}
rigidbody.velocity = 10.0f;
}
void MyFunction () {
myLight.enabled = !myLight.enabled;
}
string AddTwo (int var1, int var2) {
int returnValue = var1 + var2;
return returnValue;
}
}
No comments:
Post a Comment