-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
[Unity] Gauge example
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
[ExecuteInEditMode] | ||
[RequireComponent(typeof(SkeletonRenderer))] | ||
public class SpineGauge : MonoBehaviour{ | ||
|
||
[Range(0,1)] | ||
public float fill = 0; | ||
|
||
[SpineAnimation] | ||
public string fillAnimationName; | ||
Spine.Animation fillAnimation; | ||
|
||
SkeletonRenderer skeletonRenderer; | ||
|
||
void Start () { | ||
skeletonRenderer = GetComponent<SkeletonRenderer>(); | ||
} | ||
|
||
void Update () { | ||
|
||
var skeleton = skeletonRenderer.skeleton; | ||
|
||
if (skeleton == null) | ||
return; | ||
|
||
if (fillAnimation == null) { | ||
fillAnimation = skeleton.Data.FindAnimation(fillAnimationName); | ||
if (fillAnimation == null) | ||
return; | ||
} | ||
|
||
fillAnimation.Apply(skeleton, 0, fill, false, null); | ||
skeleton.Update(Time.deltaTime); | ||
skeleton.UpdateWorldTransform(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Gauge.png | ||
size: 1024,64 | ||
format: RGBA8888 | ||
filter: Linear,Linear | ||
repeat: none | ||
Background | ||
rotate: false | ||
xy: 254, 30 | ||
size: 224, 32 | ||
orig: 224, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
Bar | ||
rotate: false | ||
xy: 480, 30 | ||
size: 224, 32 | ||
orig: 224, 32 | ||
offset: 0, 0 | ||
index: -1 | ||
Border | ||
rotate: false | ||
xy: 2, 2 | ||
size: 250, 60 | ||
orig: 250, 60 | ||
offset: 0, 0 | ||
index: -1 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"skeleton": { "hash": "IKLl/62j+Y1bsQ8rdHoVK9PDip8", "spine": "2.1.27", "width": 250, "height": 60, "images": "./images/" }, | ||
"bones": [ | ||
{ "name": "root" }, | ||
{ "name": "Bar", "parent": "root", "x": -112.29 } | ||
], | ||
"slots": [ | ||
{ "name": "Background", "bone": "root", "attachment": "Background" }, | ||
{ "name": "Bar", "bone": "Bar", "attachment": "Bar" }, | ||
{ "name": "Border", "bone": "root", "attachment": "Border" } | ||
], | ||
"skins": { | ||
"default": { | ||
"Background": { | ||
"Background": { "width": 224, "height": 32 } | ||
}, | ||
"Bar": { | ||
"Bar": { "x": 112.29, "width": 224, "height": 32 } | ||
}, | ||
"Border": { | ||
"Border": { "width": 250, "height": 60 } | ||
} | ||
} | ||
}, | ||
"animations": { | ||
"Fill": { | ||
"bones": { | ||
"Bar": { | ||
"scale": [ | ||
{ | ||
"time": 0, | ||
"x": 0.002, | ||
"y": 1, | ||
"curve": [ 0.25, 0, 0.75, 1 ] | ||
}, | ||
{ "time": 1, "x": 1, "y": 1 } | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.