Tanoda
Point.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
9using System.Collections;
10using System.Collections.Generic;
11using UnityEngine;
12
13namespace Leap.Unity.Geometry {
14
15 [System.Serializable]
16 public struct Point {
17
18 [SerializeField]
19 public Transform transform;
20
21 [SerializeField]
22 private Vector3 _position;
23 public Vector3 position {
24 get {
25 if (transform == null) return _position;
26 else return transform.TransformPoint(_position);
27 }
28 set {
29 if (transform == null) _position = value;
30 else _position = transform.InverseTransformPoint(value);
31 }
32 }
33
34 public Point(Component transformSource = null)
35 : this(default(Vector3), transformSource) { }
36
37 public Point(Vector3 position = default(Vector3), Component transformSource = null) {
38 this.transform = transformSource.transform;
39 _position = Vector3.zero;
40 }
41
42 public static implicit operator Vector3(Point point) {
43 return point.position;
44 }
45
46 }
47
48 public static class PointExtensions {
49
50
51
52 }
53
54}
UnityEngine.Component Component
Point(Component transformSource=null)
Definition: Point.cs:34
Point(Vector3 position=default(Vector3), Component transformSource=null)
Definition: Point.cs:37
Transform transform
Definition: Point.cs:19