Tanoda
Incrementable.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 System.Collections.Generic;
11#if UNITY_EDITOR
12using UnityEditor;
13#endif
14
15namespace Leap.Unity.Attributes {
16
18 public const float BUTTON_WIDTH = 20;
19
20#if UNITY_EDITOR
21 public void Draw(Rect rect, SerializedProperty property) {
22 rect.width = BUTTON_WIDTH;
23
24 if (GUI.Button(rect, "-")) {
25 property.intValue--;
26 }
27
28 rect.x += rect.width;
29
30 if (GUI.Button(rect, "+")) {
31 property.intValue++;
32 }
33 }
34
35 public float GetWidth() {
36 return BUTTON_WIDTH * 2;
37 }
38
39 public override IEnumerable<SerializedPropertyType> SupportedTypes {
40 get {
41 yield return SerializedPropertyType.Integer;
42 }
43 }
44#endif
45 }
46}