Tanoda
SimpleAnchorFeedback.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
10using System.Collections;
11using System.Collections.Generic;
12using UnityEngine;
13
14namespace Leap.Unity.Examples {
15
16 [RequireComponent(typeof(Anchor))]
17 [AddComponentMenu("")]
18 public class SimpleAnchorFeedback : MonoBehaviour {
19
20 public Transform scaleTarget;
21
22 private Anchor _anchor;
23
24 private Vector3 _initScaleVector;
25 private float _curScale = 1F;
26
27 void Start() {
28 _anchor = GetComponent<Anchor>();
29
30 _initScaleVector = scaleTarget.transform.localScale;
31 }
32
33 void Update() {
34 float _targetScale = 1F;
35
36 if (_anchor.isPreferred) {
37 _targetScale = 1.3F;
38 }
39
40 if (_anchor.hasAnchoredObjects) {
41 _targetScale = 2.4F;
42 }
43
44 _curScale = Mathf.Lerp(_curScale, _targetScale, 20F * Time.deltaTime);
45
46 scaleTarget.transform.localScale = _curScale * _initScaleVector;
47 }
48
49 }
50
51}