Scripts VF
Scripts VF
Scripts VF
Dans le programme ci-dessous, nous avons utilisé les flèches up down left right
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
{
monVector3 = transform.position;
}
}
}
b. Interaction avec la souris
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
{
if (Input.GetMouseButton(0))
{
this.transform.localScale += new Vector3(2, 1/2, 1);
}
if (Input.GetMouseButton(1))
{
this.transform.localScale -= new Vector3(2, 1/2, 1);
}
if (Input.GetMouseButton(2))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Debug.Log(ray);
Camera.main.transform.Translate(1, 0, 1);
}
}
}
c. Changement de la couleur de l’objet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Example()
{
altColor.g = 0f;
altColor.r = 0f;
altColor.b = 0f;
altColor.a = 0f;
}
void Start()
{
//Call Example to set all color values to zero.
Example();
//Get the renderer of the object so we can access the color
rend = GetComponent<Renderer>();
//Set the initial color (0f,0f,0f,0f)
rend.material.color = altColor;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.G)) {
altColor.g += 0.1f; //Alter the color
rend.material.color = altColor; //Assign the changed color to the material
}
if (Input.GetKeyDown(KeyCode.R)) {
altColor.r += 0.1f; //Alter the color
rend.material.color = altColor;
}
if (Input.GetKeyDown(KeyCode.B)) {
altColor.b += 0.1f; //Alter the color
rend.material.color = altColor; //Assign the changed color to the material
}
if (Input.GetKeyDown(KeyCode.A)) {
altColor.a += 0.1f; //Alter the color
rend.material.color = altColor; //Assign the changed color to the material
}
}
}
d. Changement de la texture de l’objet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
currentTexture %= Textures.Length;
rend.material.mainTexture = Textures[currentTexture];
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Vuforia;
void Start()
vbBtnObj = GameObject.Find("VirtualButton");
vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonPressed(OnButt
onPressed);
vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonReleased(OnButtonReleased)
;
Debug.Log("Pressed");
obj1.SetActive(false);
Debug.Log("Released");
obj1.SetActive(true);
}
Autre script
using UnityEngine;
{ SceneManager.LoadScene(Level1); }
{ Application.Quit(); Debug.Log("exit"); }
{ SceneManager.LoadScene(SettingScene); }
{ GameObject text2;
text2 = GameObject.Find(textSetting);
{ settingWin.SetActive(true); }
{ settingWin.SetActive(false); }