VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_DebugHand.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 namespace AVR.Phys
6 {
7  /// <summary>
8  /// In-editor drawn hand for setting up GrabNodes.
9  /// </summary>
10  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_phys_1_1_a_v_r___debug_hand.html")]
11  [ExecuteInEditMode]
12  public class AVR_DebugHand : AVR.Core.AVR_Behaviour
13  {
14  public Animator animator;
15  public AVR_GrabNode node;
16  public Transform grab_point;
17 
18  // Start is called before the first frame update
19  void Start()
20  {
21  if(Application.isPlaying) {
22  GameObject.DestroyImmediate(gameObject);
23  }
24 
25  if(!grab_point) {
26  grab_point = AVR.Core.Utils.Misc.CreateEmptyGameObject("GrabPoint", transform);
27  }
28 
29  try {
30  AVR_BasicGrabProvider gp = FindObjectOfType<AVR_BasicGrabProvider>();
31 
32  grab_point.localPosition = gp.transform.InverseTransformPoint(gp.grabPoint.position);
33  } catch(System.Exception) { }
34 
35  node = GetComponentInParent<AVR_GrabNode>();
36 
37  transform.position = transform.parent.position - (grab_point.position - transform.position);
38  }
39 
40  void Update()
41  {
42  node = GetComponentInParent<AVR_GrabNode>();
43 
44  transform.localRotation = Quaternion.identity * Quaternion.Euler(node.yaw_test * node.allowed_yaw, node.pitch_test * node.allowed_pitch, node.roll_test * node.allowed_roll);
45 
46  transform.position = node.transform.position - (grab_point.position - transform.position);
47 
48  //foreach (AVR_Finger f in fingers) f.Update();
49  animator.SetLayerWeight(1, 1.0f);
50  animator.SetLayerWeight(2, 1.0f);
51  animator.SetLayerWeight(3, 1.0f);
52  animator.SetLayerWeight(4, 1.0f);
53  animator.SetLayerWeight(5, 1.0f);
54 
55  animator.Play("Proc_IndexFinger", 1, node.index_pose);
56  animator.Play("Proc_MiddleFinger", 2, node.middle_pose);
57  animator.Play("Proc_RingFinger", 3, node.ring_pose);
58  animator.Play("Proc_PinkyFinger", 4, node.pinky_pose);
59  animator.Play("Proc_ThumbFinger", 5, node.thumb_pose);
60  animator.Update(0.0f);
61  }
62  }
63 }
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Simplest GrabProvider. Grabbed objects will move their center (obj.transform.position) towards the re...
Represents a grabbable node on an AVR_Grabbable. Nodes have preset poses/constraints for the hand tha...
Definition: AVR_GrabNode.cs:15
In-editor drawn hand for setting up GrabNodes.