a.
Interaction avec le Clavier
Fichier [Link] : Interaction avec le clavier pour déplacer l’objet,
appliquer des rotations et le détruire après n secondes.
Dans le programme ci-dessous, nous avons utilisé les flèches up down left right
, les touches (Z, F1, Space et Echap)
using [Link];
using [Link];
using UnityEngine;
public class InteractionClavier : MonoBehaviour
{
// Start is called before the first frame update
public Vector3 monVector3;
void Start()
{
monVector3 = [Link];
}
// Update is called once per frame
void Update()
{
if ([Link]([Link]))
{
[Link](monVector3.x / 50, 0, 0);
// [Link](10, 0, 0);
}
else if ([Link]([Link]))
{
[Link](monVector3.x / (-50), 0, 0);
}
else if ([Link]([Link]))
{
[Link](0, monVector3.y / (20), 0);
}
else if ([Link]([Link]))
{
[Link](0, monVector3.y / (-20), 0);
}
else if ([Link](KeyCode.Z))
{
[Link](0, 0, monVector3.z / (20));
}
else if ([Link](KeyCode.F1))
{
[Link](0, 0, monVector3.z / (-20));
}
else if ([Link]([Link]))
{
[Link](45, 0, 0);
//[Link](0, 45, 0);
//[Link](0, 0, 45);
//[Link](45, 0, 45);
}
else if ([Link]([Link]))
{
Destroy(gameObject, 10); // Détruire l’objet après 10s
}
}
}
b. Interaction avec la souris
Fichier [Link]: Interaction avec la souris pour redimensionner l’objet et
déplacer la main caméra.
using [Link];
using [Link];
using UnityEngine;
public class InteractionSouris : MonoBehaviour
{
void Start()
{
// Update is called once per frame
void Update()
{
if ([Link](0))
{
[Link] += new Vector3(2, 1/2, 1);
}
if ([Link](1))
{
[Link] -= new Vector3(2, 1/2, 1);
}
if ([Link](2))
{
Ray ray = [Link]([Link]);
[Link](ray);
[Link](1, 0, 1);
}
}
}
c. Changement de la couleur de l’objet
Fichier [Link]: Changement de la couleur RGBA de l’objet, en appuyant sur R
et/ou G et/ou B pour augmenter respectivement son intensité de rouge, vert et bleu.
using [Link];
using [Link];
using UnityEngine;
public class ChangeMaterial : MonoBehaviour
{
public Color altColor = [Link];
public Renderer rend;
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)
[Link] = altColor;
}
void Update()
{
if ([Link](KeyCode.G)) {
altColor.g += 0.1f; //Alter the color
[Link] = altColor; //Assign the changed color to the material
}
if ([Link](KeyCode.R)) {
altColor.r += 0.1f; //Alter the color
[Link] = altColor;
}
if ([Link](KeyCode.B)) {
altColor.b += 0.1f; //Alter the color
[Link] = altColor; //Assign the changed color to the material
}
if ([Link](KeyCode.A)) {
altColor.a += 0.1f; //Alter the color
[Link] = altColor; //Assign the changed color to the material
}
}
}
d. Changement de la texture de l’objet
Fichier [Link]: Changement de la texture de l’objet
using [Link];
using [Link];
using UnityEngine;
public class ChangeTexture : MonoBehaviour
{
public Texture[] Textures;
public int currentTexture;
public Renderer rend;
// Start is called before the first frame update
void Start()
{
// Update is called once per frame
void Update()
{
if ([Link]([Link]))
{
currentTexture++;
if ([Link] == 0)
return;
currentTexture %= [Link];
[Link] = Textures[currentTexture];
}
}
}
e. Réalisation d’un bouton avec un lien
public void buttonFunction(string buttonLink)
{ [Link](buttonLink); }
// Pour site web : [Link]
// Pour mail : mailto: Webmaster@[Link]
// Pour tel : tel: + 21671603498
f. Réalisation d’un bouton virtuel
using [Link];
using [Link];
using UnityEngine;
using [Link];
using Vuforia;
public class VBtnFonction : MonoBehaviour
public GameObject vbBtnObj;
public GameObject obj1;
void Start()
vbBtnObj = [Link]("VirtualButton");
[Link]<VirtualButtonBehaviour>().RegisterOnButtonPressed(OnButt
onPressed);
[Link]<VirtualButtonBehaviour>().RegisterOnButtonReleased(OnButtonReleased)
;
public void OnButtonPressed(VirtualButtonBehaviour vb)
[Link]("Pressed");
[Link](false);
public void OnButtonReleased(VirtualButtonBehaviour vb)
[Link]("Released");
[Link](true);
}
Autre script
using UnityEngine;
public class MenuScript : MonoBehaviour {
public void Play(string Level1)
{ [Link](Level1); }
public void Exit()
{ [Link](); [Link]("exit"); }
public void Setting1(string SettingScene)
{ [Link](SettingScene); }
public void Setting2(string textSetting)
{ GameObject text2;
text2 = [Link](textSetting);
[Link]<Text>().text = "Setting Text here"; }
public GameObject settingWin;
public void SettingButtom( )
{ [Link](true); }
public void CloseSetting()
{ [Link](false); }