private static void DrawTarget(ARMarker m, Matrix4x4 mat, GizmoType type) { float length = m.length; if (length > 0.0f) { Vector3 origin = mat.GetColumn(3); Vector3 right = mat.GetColumn(0); Vector3 up = mat.GetColumn(1); Vector3 centre = origin - right * 0.5f + up * 0.5f; Vector3 size = new Vector3(0.01f, 0.01f, 0.01f); Gizmos.color = CubeColor; Gizmos.DrawCube(centre, size); if ((type & GizmoType.Selected) != 0) { DrawRectangle(centre, up, right, 0.05f, SelectedColor); } else if ((type & GizmoType.NotInSelectionHierarchy) != 0) { DrawRectangle(centre, up, right, 0.05f, NotInSelectionHierarchyColor); } } }
static void RenderARTrackedObjectGizmo(ARMarker to, GizmoType gizmoType) { if (to == null) { return; } Matrix4x4 pose = to.gameObject.transform.localToWorldMatrix; DrawTarget(to, pose, gizmoType); }
public override void OnInspectorGUI() { ARMarker marker = (ARMarker)target; if (marker == null) { return; } string idlabel = String.Format("id [0,{0})", NativePlugin.get_dictionary_words()); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(idlabel); marker.SetID(EditorGUILayout.IntField(marker.id)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("length(m)"); marker.length = EditorGUILayout.FloatField(marker.length); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("use background color"); marker.SetUseBackgroundColor(EditorGUILayout.Toggle(marker.useBackgroundColor)); EditorGUILayout.EndHorizontal(); if (marker.useBackgroundColor) { marker.SetBackgroundColor(EditorGUILayout.ColorField("background color", marker.backgroundColor)); } else { EditorGUILayout.ObjectField("texture", marker.texture, typeof(Texture2D), true); } }