Changement couleur quand on passer le curseur sur les obj
This commit is contained in:
parent
2610e3efae
commit
f7cb452241
|
@ -8,10 +8,40 @@ public class OnClickedMoveCamera : MonoBehaviour {
|
||||||
public Transform destination;
|
public Transform destination;
|
||||||
public CameraController camCtrl;
|
public CameraController camCtrl;
|
||||||
|
|
||||||
|
private Color clrBase;
|
||||||
|
private Color clrTarget;
|
||||||
|
private Renderer[] children;
|
||||||
|
|
||||||
void OnMouseDown()
|
void Awake(){
|
||||||
{
|
clrBase = renderer.material.color;
|
||||||
|
clrTarget = clrBase;
|
||||||
|
children = GetComponentsInChildren<Renderer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OnMouseDown(){
|
||||||
|
//Move to position
|
||||||
camCtrl.targetPos = destination.position;
|
camCtrl.targetPos = destination.position;
|
||||||
camCtrl.targetRot = destination.rotation;
|
camCtrl.targetRot = destination.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnMouseEnter(){
|
||||||
|
//Lerp to hilight color
|
||||||
|
clrTarget = new Color(1.0F, 0.87F, 0.75F);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnMouseExit(){
|
||||||
|
//Lerp to base color
|
||||||
|
clrTarget = clrBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update(){
|
||||||
|
//Lerp to clrTarget
|
||||||
|
Color clr = Color.Lerp(renderer.material.color, clrTarget, Time.deltaTime * 10);
|
||||||
|
|
||||||
|
//Fixme? Any newly created chilren wont be lerped
|
||||||
|
foreach (Renderer child in children) {
|
||||||
|
child.material.color = clr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue