Tanoda
LeapGraphicEditorApi.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 UnityEngine;
10using Leap.Unity.Space;
11
13
14 public abstract partial class LeapGraphic : MonoBehaviour {
15
16#if UNITY_EDITOR
17 public EditorApi editor { get; protected set; }
18
19 public class EditorApi {
20 private readonly LeapGraphic _graphic;
21
22 public Mesh pickingMesh;
23
24 public EditorApi(LeapGraphic graphic) {
25 _graphic = graphic;
26 }
27
28 public virtual void OnValidate() {
29 _graphic.isRepresentationDirty = true;
30
31 foreach (var data in _graphic._featureData) {
32 data.MarkFeatureDirty();
33 }
34
35 if (!Application.isPlaying) {
36 if (_graphic.isAttachedToGroup && !_graphic.transform.IsChildOf(_graphic._attachedRenderer.transform)) {
37 _graphic.OnDetachedFromGroup();
38 }
39
40 if (_graphic.isAttachedToGroup) {
41 _graphic._attachedRenderer.editor.ScheduleRebuild();
42 _graphic._preferredRendererType = _graphic.attachedGroup.renderingMethod.GetType();
43 }
44 } else {
45 var group = _graphic.attachedGroup;
46 if (group != null) {
47 if (!group.graphics.Contains(_graphic)) {
48 _graphic.OnDetachedFromGroup();
49 group.TryAddGraphic(_graphic);
50 }
51 }
52 }
53 }
54
55 public virtual void OnDrawGizmos() {
56 if (pickingMesh != null && pickingMesh.vertexCount != 0) {
57 Gizmos.color = new Color(1, 0, 0, 0);
58 Gizmos.DrawMesh(pickingMesh);
59 }
60 }
61
67 public virtual void RebuildEditorPickingMesh() { }
68
73 public virtual void OnAttachedToGroup(LeapGraphicGroup group, LeapSpaceAnchor anchor) {
74 if (!Application.isPlaying) {
75 _graphic._preferredRendererType = group.renderingMethod.GetType();
76 }
77 }
78 }
79#endif
80 }
81}
UnityEngine.Color Color
Definition: TestScript.cs:32
LeapRenderingMethod renderingMethod
Gets the rendering method used for this group. This can only be changed at edit time using either the...
LeapSpaceAnchor anchor
Returns the space anchor for this graphic. This will be null if the graphic is not currently part of ...
Definition: LeapGraphic.cs:108
virtual void OnAttachedToGroup(LeapGraphicGroup group, LeapSpaceAnchor anchor)
Called by the system when this graphic is attached to a group. This method is invoked both at runtime...
Definition: LeapGraphic.cs:272