2
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class Raptor : MonoBehaviour {
|
||||
|
||||
#region Inspector
|
||||
public AnimationReferenceAsset walk;
|
||||
public AnimationReferenceAsset gungrab;
|
||||
public AnimationReferenceAsset gunkeep;
|
||||
#endregion
|
||||
|
||||
SkeletonAnimation skeletonAnimation;
|
||||
|
||||
void Start () {
|
||||
skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||
StartCoroutine(GunGrabRoutine());
|
||||
}
|
||||
|
||||
IEnumerator GunGrabRoutine () {
|
||||
// Play the walk animation on track 0.
|
||||
skeletonAnimation.AnimationState.SetAnimation(0, walk, true);
|
||||
|
||||
// Repeatedly play the gungrab and gunkeep animation on track 1.
|
||||
while (true) {
|
||||
yield return new WaitForSeconds(Random.Range(0.5f, 3f));
|
||||
skeletonAnimation.AnimationState.SetAnimation(1, gungrab, false);
|
||||
|
||||
yield return new WaitForSeconds(Random.Range(0.5f, 3f));
|
||||
skeletonAnimation.AnimationState.SetAnimation(1, gunkeep, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b0d38dc0b91fb443a41838d475ae49b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class HeroEffectsHandlerExample : MonoBehaviour {
|
||||
public BasicPlatformerController eventSource;
|
||||
public UnityEvent OnJump, OnLand, OnHardLand;
|
||||
|
||||
public void Awake () {
|
||||
if (eventSource == null)
|
||||
return;
|
||||
|
||||
eventSource.OnLand += OnLand.Invoke;
|
||||
eventSource.OnJump += OnJump.Invoke;
|
||||
eventSource.OnHardLand += OnHardLand.Invoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a0f8a82c5d8a334db6996478778b892
|
||||
timeCreated: 1545916292
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,77 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HurtFlashEffect : MonoBehaviour {
|
||||
|
||||
const int DefaultFlashCount = 3;
|
||||
|
||||
public int flashCount = DefaultFlashCount;
|
||||
public Color flashColor = Color.white;
|
||||
[Range(1f/120f, 1f/15f)]
|
||||
public float interval = 1f/60f;
|
||||
public string fillPhaseProperty = "_FillPhase";
|
||||
public string fillColorProperty = "_FillColor";
|
||||
|
||||
MaterialPropertyBlock mpb;
|
||||
MeshRenderer meshRenderer;
|
||||
|
||||
public void Flash () {
|
||||
if (mpb == null) mpb = new MaterialPropertyBlock();
|
||||
if (meshRenderer == null) meshRenderer = GetComponent<MeshRenderer>();
|
||||
meshRenderer.GetPropertyBlock(mpb);
|
||||
|
||||
StartCoroutine(FlashRoutine());
|
||||
}
|
||||
|
||||
IEnumerator FlashRoutine () {
|
||||
if (flashCount < 0) flashCount = DefaultFlashCount;
|
||||
int fillPhase = Shader.PropertyToID(fillPhaseProperty);
|
||||
int fillColor = Shader.PropertyToID(fillColorProperty);
|
||||
|
||||
var wait = new WaitForSeconds(interval);
|
||||
|
||||
for (int i = 0; i < flashCount; i++) {
|
||||
mpb.SetColor(fillColor, flashColor);
|
||||
mpb.SetFloat(fillPhase, 1f);
|
||||
meshRenderer.SetPropertyBlock(mpb);
|
||||
yield return wait;
|
||||
|
||||
mpb.SetFloat(fillPhase, 0f);
|
||||
meshRenderer.SetPropertyBlock(mpb);
|
||||
yield return wait;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 395f769061839bf488f157c37d23835d
|
||||
timeCreated: 1497416645
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class MaterialPropertyBlockExample : MonoBehaviour {
|
||||
|
||||
public float timeInterval = 1f;
|
||||
public Gradient randomColors = new Gradient();
|
||||
public string colorPropertyName = "_FillColor";
|
||||
|
||||
MaterialPropertyBlock mpb;
|
||||
float timeToNextColor = 0;
|
||||
|
||||
void Start () {
|
||||
mpb = new MaterialPropertyBlock();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if (timeToNextColor <= 0) {
|
||||
timeToNextColor = timeInterval;
|
||||
|
||||
Color newColor = randomColors.Evaluate(UnityEngine.Random.value);
|
||||
mpb.SetColor(colorPropertyName, newColor);
|
||||
GetComponent<MeshRenderer>().SetPropertyBlock(mpb);
|
||||
}
|
||||
|
||||
timeToNextColor -= Time.deltaTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0456e5bde0b34594782f280f40128902
|
||||
timeCreated: 1516388202
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,75 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class MaterialReplacementExample : MonoBehaviour {
|
||||
|
||||
public Material originalMaterial;
|
||||
public Material replacementMaterial;
|
||||
public bool replacementEnabled = true;
|
||||
public SkeletonAnimation skeletonAnimation;
|
||||
|
||||
[Space]
|
||||
public string phasePropertyName = "_FillPhase";
|
||||
[Range(0f, 1f)] public float phase = 1f;
|
||||
|
||||
bool previousEnabled;
|
||||
MaterialPropertyBlock mpb;
|
||||
|
||||
void Start () {
|
||||
previousEnabled = replacementEnabled;
|
||||
SetReplacementEnabled(replacementEnabled);
|
||||
mpb = new MaterialPropertyBlock();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
mpb.SetFloat(phasePropertyName, phase);
|
||||
GetComponent<MeshRenderer>().SetPropertyBlock(mpb);
|
||||
|
||||
if (previousEnabled != replacementEnabled)
|
||||
SetReplacementEnabled(replacementEnabled);
|
||||
|
||||
previousEnabled = replacementEnabled;
|
||||
|
||||
}
|
||||
|
||||
void SetReplacementEnabled (bool active) {
|
||||
if (replacementEnabled) {
|
||||
skeletonAnimation.CustomMaterialOverride[originalMaterial] = replacementMaterial;
|
||||
} else {
|
||||
skeletonAnimation.CustomMaterialOverride.Remove(originalMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62982591830b87b45a3f6efd3ee82630
|
||||
timeCreated: 1539082420
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deef60f3c6fd9ae45b2c4dfcac0706f1
|
||||
folderAsset: yes
|
||||
timeCreated: 1545227769
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,51 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
// This StateMachineBehaviour handles sending the Mecanim state information to the component that handles playing the Spine animations.
|
||||
public class MecanimToAnimationHandleExample : StateMachineBehaviour {
|
||||
SkeletonAnimationHandleExample animationHandle;
|
||||
bool initialized;
|
||||
|
||||
override public void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
|
||||
if (!initialized) {
|
||||
animationHandle = animator.GetComponent<SkeletonAnimationHandleExample>();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
animationHandle.PlayAnimationForState(stateInfo.shortNameHash, layerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16f3a0143bc0dbc4793717b6d2ff94a2
|
||||
timeCreated: 1545230670
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdfae2bc4b385b84eb4f5f6855d0f991
|
||||
folderAsset: yes
|
||||
timeCreated: 1537527020
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39dcbd139c9316f46919f47f9706ca79
|
||||
folderAsset: yes
|
||||
timeCreated: 1522686452
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,50 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class MixAndMatchSkinsButtonExample : MonoBehaviour {
|
||||
|
||||
public SkeletonDataAsset skeletonDataAsset;
|
||||
public MixAndMatchSkinsExample skinsSystem;
|
||||
|
||||
[SpineSkin(dataField:"skeletonDataAsset")] public string itemSkin;
|
||||
public MixAndMatchSkinsExample.ItemType itemType;
|
||||
|
||||
void Start () {
|
||||
var button = GetComponent<Button>();
|
||||
button.onClick.AddListener(
|
||||
delegate { skinsSystem.Equip(itemSkin, itemType); }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c32a308f5ae4c534991805c82c575058
|
||||
timeCreated: 1522744049
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,195 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
public class MixAndMatchSkinsExample : MonoBehaviour {
|
||||
|
||||
// character skins
|
||||
[SpineSkin] public string baseSkin = "skin-base";
|
||||
[SpineSkin] public string eyelidsSkin = "eyelids/girly";
|
||||
|
||||
// here we use arrays of strings to be able to cycle between them easily.
|
||||
[SpineSkin] public string[] hairSkins = { "hair/brown", "hair/blue", "hair/pink", "hair/short-red", "hair/long-blue-with-scarf" };
|
||||
public int activeHairIndex = 0;
|
||||
[SpineSkin] public string[] eyesSkins = { "eyes/violet", "eyes/green", "eyes/yellow" };
|
||||
public int activeEyesIndex = 0;
|
||||
[SpineSkin] public string[] noseSkins = { "nose/short", "nose/long" };
|
||||
public int activeNoseIndex = 0;
|
||||
|
||||
// equipment skins
|
||||
public enum ItemType {
|
||||
Cloth,
|
||||
Pants,
|
||||
Bag,
|
||||
Hat
|
||||
}
|
||||
[SpineSkin] public string clothesSkin = "clothes/hoodie-orange";
|
||||
[SpineSkin] public string pantsSkin = "legs/pants-jeans";
|
||||
[SpineSkin] public string bagSkin = "";
|
||||
[SpineSkin] public string hatSkin = "accessories/hat-red-yellow";
|
||||
|
||||
SkeletonAnimation skeletonAnimation;
|
||||
// This "naked body" skin will likely change only once upon character creation,
|
||||
// so we store this combined set of non-equipment Skins for later re-use.
|
||||
Skin characterSkin;
|
||||
|
||||
// for repacking the skin to a new atlas texture
|
||||
public Material runtimeMaterial;
|
||||
public Texture2D runtimeAtlas;
|
||||
|
||||
void Awake () {
|
||||
skeletonAnimation = this.GetComponent<SkeletonAnimation>();
|
||||
}
|
||||
|
||||
void Start () {
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void NextHairSkin() {
|
||||
activeHairIndex = (activeHairIndex + 1) % hairSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void PrevHairSkin () {
|
||||
activeHairIndex = (activeHairIndex + hairSkins.Length - 1) % hairSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void NextEyesSkin () {
|
||||
activeEyesIndex = (activeEyesIndex + 1) % eyesSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void PrevEyesSkin () {
|
||||
activeEyesIndex = (activeEyesIndex + eyesSkins.Length - 1) % eyesSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void NextNoseSkin () {
|
||||
activeNoseIndex = (activeNoseIndex + 1) % noseSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void PrevNoseSkin () {
|
||||
activeNoseIndex = (activeNoseIndex + noseSkins.Length - 1) % noseSkins.Length;
|
||||
UpdateCharacterSkin();
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void Equip(string itemSkin, ItemType itemType) {
|
||||
switch (itemType) {
|
||||
case ItemType.Cloth:
|
||||
clothesSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Pants:
|
||||
pantsSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Bag:
|
||||
bagSkin = itemSkin;
|
||||
break;
|
||||
case ItemType.Hat:
|
||||
hatSkin = itemSkin;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UpdateCombinedSkin();
|
||||
}
|
||||
|
||||
public void OptimizeSkin () {
|
||||
// Create a repacked skin.
|
||||
var previousSkin = skeletonAnimation.Skeleton.Skin;
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
Skin repackedSkin = previousSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
|
||||
previousSkin.Clear();
|
||||
|
||||
// Use the repacked skin.
|
||||
skeletonAnimation.Skeleton.Skin = repackedSkin;
|
||||
skeletonAnimation.Skeleton.SetSlotsToSetupPose();
|
||||
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);
|
||||
|
||||
// `GetRepackedSkin()` and each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true`
|
||||
// cache necessarily created Texture copies which can be cleared by calling AtlasUtilities.ClearCache().
|
||||
// You can optionally clear the textures cache after multiple repack operations.
|
||||
// Just be aware that while this cleanup frees up memory, it is also a costly operation
|
||||
// and will likely cause a spike in the framerate.
|
||||
AtlasUtilities.ClearCache();
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
void UpdateCharacterSkin () {
|
||||
var skeleton = skeletonAnimation.Skeleton;
|
||||
var skeletonData = skeleton.Data;
|
||||
characterSkin = new Skin("character-base");
|
||||
// Note that the result Skin returned by calls to skeletonData.FindSkin()
|
||||
// could be cached once in Start() instead of searching for the same skin
|
||||
// every time. For demonstration purposes we keep it simple here.
|
||||
characterSkin.AddSkin(skeletonData.FindSkin(baseSkin));
|
||||
characterSkin.AddSkin(skeletonData.FindSkin(noseSkins[activeNoseIndex]));
|
||||
characterSkin.AddSkin(skeletonData.FindSkin(eyelidsSkin));
|
||||
characterSkin.AddSkin(skeletonData.FindSkin(eyesSkins[activeEyesIndex]));
|
||||
characterSkin.AddSkin(skeletonData.FindSkin(hairSkins[activeHairIndex]));
|
||||
}
|
||||
|
||||
void AddEquipmentSkinsTo (Skin combinedSkin) {
|
||||
var skeleton = skeletonAnimation.Skeleton;
|
||||
var skeletonData = skeleton.Data;
|
||||
combinedSkin.AddSkin(skeletonData.FindSkin(clothesSkin));
|
||||
combinedSkin.AddSkin(skeletonData.FindSkin(pantsSkin));
|
||||
if (!string.IsNullOrEmpty(bagSkin)) combinedSkin.AddSkin(skeletonData.FindSkin(bagSkin));
|
||||
if (!string.IsNullOrEmpty(hatSkin)) combinedSkin.AddSkin(skeletonData.FindSkin(hatSkin));
|
||||
}
|
||||
|
||||
void UpdateCombinedSkin () {
|
||||
var skeleton = skeletonAnimation.Skeleton;
|
||||
var resultCombinedSkin = new Skin("character-combined");
|
||||
|
||||
resultCombinedSkin.AddSkin(characterSkin);
|
||||
AddEquipmentSkinsTo(resultCombinedSkin);
|
||||
|
||||
skeleton.SetSkin(resultCombinedSkin);
|
||||
skeleton.SetSlotsToSetupPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5a66492fdefc494b8399943a0f9b250
|
||||
timeCreated: 1601458489
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,150 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
// This is an example script that shows you how to change images on your skeleton using UnityEngine.Sprites.
|
||||
public class MixAndMatch : MonoBehaviour {
|
||||
|
||||
#region Inspector
|
||||
[SpineSkin]
|
||||
public string templateAttachmentsSkin = "base";
|
||||
public Material sourceMaterial; // This will be used as the basis for shader and material property settings.
|
||||
|
||||
[Header("Visor")]
|
||||
public Sprite visorSprite;
|
||||
[SpineSlot] public string visorSlot;
|
||||
[SpineAttachment(slotField:"visorSlot", skinField:"baseSkinName")] public string visorKey = "goggles";
|
||||
|
||||
[Header("Gun")]
|
||||
public Sprite gunSprite;
|
||||
[SpineSlot] public string gunSlot;
|
||||
[SpineAttachment(slotField:"gunSlot", skinField:"baseSkinName")] public string gunKey = "gun";
|
||||
|
||||
[Header("Runtime Repack")]
|
||||
public bool repack = true;
|
||||
public BoundingBoxFollower bbFollower;
|
||||
|
||||
[Header("Do not assign")]
|
||||
public Texture2D runtimeAtlas;
|
||||
public Material runtimeMaterial;
|
||||
#endregion
|
||||
|
||||
Skin customSkin;
|
||||
|
||||
void OnValidate () {
|
||||
if (sourceMaterial == null) {
|
||||
var skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||
if (skeletonAnimation != null)
|
||||
sourceMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Start () {
|
||||
yield return new WaitForSeconds(1f); // Delay for one second before applying. For testing.
|
||||
Apply();
|
||||
}
|
||||
|
||||
void Apply () {
|
||||
var skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||
var skeleton = skeletonAnimation.Skeleton;
|
||||
|
||||
// STEP 0: PREPARE SKINS
|
||||
// Let's prepare a new skin to be our custom skin with equips/customizations. We get a clone so our original skins are unaffected.
|
||||
customSkin = customSkin ?? new Skin("custom skin"); // This requires that all customizations are done with skin placeholders defined in Spine.
|
||||
//customSkin = customSkin ?? skeleton.UnshareSkin(true, false, skeletonAnimation.AnimationState); // use this if you are not customizing on the default skin.
|
||||
var templateSkin = skeleton.Data.FindSkin(templateAttachmentsSkin);
|
||||
|
||||
// STEP 1: "EQUIP" ITEMS USING SPRITES
|
||||
// STEP 1.1 Find the original/template attachment.
|
||||
// Step 1.2 Get a clone of the original/template attachment.
|
||||
// Step 1.3 Apply the Sprite image to the clone.
|
||||
// Step 1.4 Add the remapped clone to the new custom skin.
|
||||
|
||||
// Let's do this for the visor.
|
||||
int visorSlotIndex = skeleton.FindSlotIndex(visorSlot); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster.
|
||||
Attachment templateAttachment = templateSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1
|
||||
Attachment newAttachment = templateAttachment.GetRemappedClone(visorSprite, sourceMaterial, pivotShiftsMeshUVCoords : false); // STEP 1.2 - 1.3
|
||||
// Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates
|
||||
// a cached Texture copy which can be cleared by calling AtlasUtilities.ClearCache() as done in the method below.
|
||||
customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4
|
||||
|
||||
// And now for the gun.
|
||||
int gunSlotIndex = skeleton.FindSlotIndex(gunSlot);
|
||||
Attachment templateGun = templateSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1
|
||||
Attachment newGun = templateGun.GetRemappedClone(gunSprite, sourceMaterial, pivotShiftsMeshUVCoords: false); // STEP 1.2 - 1.3
|
||||
if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4
|
||||
|
||||
// customSkin.RemoveAttachment(gunSlotIndex, gunKey); // To remove an item.
|
||||
// customSkin.Clear()
|
||||
// Use skin.Clear() To remove all customizations.
|
||||
// Customizations will fall back to the value in the default skin if it was defined there.
|
||||
// To prevent fallback from happening, make sure the key is not defined in the default skin.
|
||||
|
||||
// STEP 3: APPLY AND CLEAN UP.
|
||||
// Recommended, preferably at level-load-time: REPACK THE CUSTOM SKIN TO MINIMIZE DRAW CALLS
|
||||
// IMPORTANT NOTE: the GetRepackedSkin() operation is expensive - if multiple characters
|
||||
// need to call it every few seconds the overhead will outweigh the draw call benefits.
|
||||
//
|
||||
// Repacking requires that you set all source textures/sprites/atlases to be Read/Write enabled in the inspector.
|
||||
// Combine all the attachment sources into one skin. Usually this means the default skin and the custom skin.
|
||||
// call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture.
|
||||
if (repack) {
|
||||
var repackedSkin = new Skin("repacked skin");
|
||||
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
|
||||
repackedSkin.AddAttachments(customSkin); // Include your new custom skin.
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
|
||||
skeleton.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
|
||||
if (bbFollower != null) bbFollower.Initialize(true);
|
||||
} else {
|
||||
skeleton.SetSkin(customSkin); // Just use the custom skin directly.
|
||||
}
|
||||
|
||||
skeleton.SetSlotsToSetupPose(); // Use the pose from setup pose.
|
||||
skeletonAnimation.Update(0); // Use the pose in the currently active animation.
|
||||
|
||||
// `GetRepackedSkin()` and each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true`
|
||||
// cache necessarily created Texture copies which can be cleared by calling AtlasUtilities.ClearCache().
|
||||
// You can optionally clear the textures cache after multiple repack operations.
|
||||
// Just be aware that while this cleanup frees up memory, it is also a costly operation
|
||||
// and will likely cause a spike in the framerate.
|
||||
AtlasUtilities.ClearCache();
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdd7c8b428f700c438a6a14addca0346
|
||||
timeCreated: 1480089275
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,149 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity.AttachmentTools;
|
||||
using System.Collections;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
// This is an example script that shows you how to change images on your skeleton using UnityEngine.Sprites.
|
||||
public class MixAndMatchGraphic : MonoBehaviour {
|
||||
|
||||
#region Inspector
|
||||
[SpineSkin]
|
||||
public string baseSkinName = "base";
|
||||
public Material sourceMaterial; // This will be used as the basis for shader and material property settings.
|
||||
|
||||
[Header("Visor")]
|
||||
public Sprite visorSprite;
|
||||
[SpineSlot] public string visorSlot;
|
||||
[SpineAttachment(slotField:"visorSlot", skinField:"baseSkinName")] public string visorKey = "goggles";
|
||||
|
||||
[Header("Gun")]
|
||||
public Sprite gunSprite;
|
||||
[SpineSlot] public string gunSlot;
|
||||
[SpineAttachment(slotField:"gunSlot", skinField:"baseSkinName")] public string gunKey = "gun";
|
||||
|
||||
[Header("Runtime Repack Required!!")]
|
||||
public bool repack = true;
|
||||
|
||||
[Header("Do not assign")]
|
||||
public Texture2D runtimeAtlas;
|
||||
public Material runtimeMaterial;
|
||||
#endregion
|
||||
|
||||
Skin customSkin;
|
||||
|
||||
void OnValidate () {
|
||||
if (sourceMaterial == null) {
|
||||
var skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
if (skeletonGraphic != null)
|
||||
sourceMaterial = skeletonGraphic.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Start () {
|
||||
yield return new WaitForSeconds(1f); // Delay for 1 second. For testing.
|
||||
Apply();
|
||||
}
|
||||
|
||||
[ContextMenu("Apply")]
|
||||
void Apply () {
|
||||
var skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
var skeleton = skeletonGraphic.Skeleton;
|
||||
|
||||
// STEP 0: PREPARE SKINS
|
||||
// Let's prepare a new skin to be our custom skin with equips/customizations. We get a clone so our original skins are unaffected.
|
||||
customSkin = customSkin ?? new Skin("custom skin"); // This requires that all customizations are done with skin placeholders defined in Spine.
|
||||
//customSkin = customSkin ?? skeleton.UnshareSkin(true, false, skeletonAnimation.AnimationState); // use this if you are not customizing on the default skin and don't plan to remove
|
||||
// Next let's get the skin that contains our source attachments. These are the attachments that
|
||||
var baseSkin = skeleton.Data.FindSkin(baseSkinName);
|
||||
|
||||
// STEP 1: "EQUIP" ITEMS USING SPRITES
|
||||
// STEP 1.1 Find the original attachment.
|
||||
// Step 1.2 Get a clone of the original attachment.
|
||||
// Step 1.3 Apply the Sprite image to it.
|
||||
// Step 1.4 Add the remapped clone to the new custom skin.
|
||||
|
||||
// Let's do this for the visor.
|
||||
int visorSlotIndex = skeleton.FindSlotIndex(visorSlot); // You can access GetAttachment and SetAttachment via string, but caching the slotIndex is faster.
|
||||
Attachment baseAttachment = baseSkin.GetAttachment(visorSlotIndex, visorKey); // STEP 1.1
|
||||
Attachment newAttachment = baseAttachment.GetRemappedClone(visorSprite, sourceMaterial); // STEP 1.2 - 1.3
|
||||
// Note: Each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true` creates
|
||||
// a cached Texture copy which can be cleared by calling AtlasUtilities.ClearCache() as done below.
|
||||
customSkin.SetAttachment(visorSlotIndex, visorKey, newAttachment); // STEP 1.4
|
||||
|
||||
// And now for the gun.
|
||||
int gunSlotIndex = skeleton.FindSlotIndex(gunSlot);
|
||||
Attachment baseGun = baseSkin.GetAttachment(gunSlotIndex, gunKey); // STEP 1.1
|
||||
Attachment newGun = baseGun.GetRemappedClone(gunSprite, sourceMaterial); // STEP 1.2 - 1.3
|
||||
if (newGun != null) customSkin.SetAttachment(gunSlotIndex, gunKey, newGun); // STEP 1.4
|
||||
|
||||
// customSkin.RemoveAttachment(gunSlotIndex, gunKey); // To remove an item.
|
||||
// customSkin.Clear()
|
||||
// Use skin.Clear() To remove all customizations.
|
||||
// Customizations will fall back to the value in the default skin if it was defined there.
|
||||
// To prevent fallback from happening, make sure the key is not defined in the default skin.
|
||||
|
||||
// STEP 3: APPLY AND CLEAN UP.
|
||||
// Recommended: REPACK THE CUSTOM SKIN TO MINIMIZE DRAW CALLS
|
||||
// Repacking requires that you set all source textures/sprites/atlases to be Read/Write enabled in the inspector.
|
||||
// Combine all the attachment sources into one skin. Usually this means the default skin and the custom skin.
|
||||
// call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture.
|
||||
if (repack) {
|
||||
var repackedSkin = new Skin("repacked skin");
|
||||
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin);
|
||||
repackedSkin.AddAttachments(customSkin);
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas);
|
||||
skeleton.SetSkin(repackedSkin);
|
||||
} else {
|
||||
skeleton.SetSkin(customSkin);
|
||||
}
|
||||
|
||||
//skeleton.SetSlotsToSetupPose();
|
||||
skeleton.SetToSetupPose();
|
||||
skeletonGraphic.Update(0);
|
||||
skeletonGraphic.OverrideTexture = runtimeAtlas;
|
||||
|
||||
// `GetRepackedSkin()` and each call to `GetRemappedClone()` with parameter `premultiplyAlpha` set to `true`
|
||||
// cache necessarily created Texture copies which can be cleared by calling AtlasUtilities.ClearCache().
|
||||
// You can optionally clear the textures cache after multiple repack operations.
|
||||
// Just be aware that while this cleanup frees up memory, it is also a costly operation
|
||||
// and will likely cause a spike in the framerate.
|
||||
AtlasUtilities.ClearCache();
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e24c5293ec0b444eba7a2680caa925f
|
||||
timeCreated: 1480089275
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,102 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class RaggedySpineboy : MonoBehaviour {
|
||||
|
||||
public LayerMask groundMask;
|
||||
public float restoreDuration = 0.5f;
|
||||
public Vector2 launchVelocity = new Vector2(50,100);
|
||||
|
||||
Spine.Unity.Examples.SkeletonRagdoll2D ragdoll;
|
||||
Collider2D naturalCollider;
|
||||
|
||||
void Start () {
|
||||
ragdoll = GetComponent<Spine.Unity.Examples.SkeletonRagdoll2D>();
|
||||
naturalCollider = GetComponent<Collider2D>();
|
||||
}
|
||||
|
||||
void AddRigidbody () {
|
||||
var rb = gameObject.AddComponent<Rigidbody2D>();
|
||||
rb.freezeRotation = true;
|
||||
naturalCollider.enabled = true;
|
||||
}
|
||||
|
||||
void RemoveRigidbody () {
|
||||
Destroy(GetComponent<Rigidbody2D>());
|
||||
naturalCollider.enabled = false;
|
||||
}
|
||||
|
||||
void OnMouseUp () {
|
||||
if (naturalCollider.enabled)
|
||||
Launch();
|
||||
}
|
||||
|
||||
void Launch () {
|
||||
RemoveRigidbody();
|
||||
ragdoll.Apply();
|
||||
ragdoll.RootRigidbody.velocity = new Vector2(Random.Range(-launchVelocity.x, launchVelocity.x), launchVelocity.y);
|
||||
StartCoroutine(WaitUntilStopped());
|
||||
}
|
||||
|
||||
IEnumerator Restore () {
|
||||
Vector3 estimatedPos = ragdoll.EstimatedSkeletonPosition;
|
||||
Vector3 rbPosition = ragdoll.RootRigidbody.position;
|
||||
|
||||
Vector3 skeletonPoint = estimatedPos;
|
||||
RaycastHit2D hit = Physics2D.Raycast((Vector2)rbPosition, (Vector2)(estimatedPos - rbPosition), Vector3.Distance(estimatedPos, rbPosition), groundMask);
|
||||
if (hit.collider != null)
|
||||
skeletonPoint = hit.point;
|
||||
|
||||
ragdoll.RootRigidbody.isKinematic = true;
|
||||
ragdoll.SetSkeletonPosition(skeletonPoint);
|
||||
|
||||
yield return ragdoll.SmoothMix(0, restoreDuration);
|
||||
ragdoll.Remove();
|
||||
|
||||
AddRigidbody();
|
||||
}
|
||||
|
||||
IEnumerator WaitUntilStopped () {
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
float t = 0;
|
||||
while (t < 0.5f) {
|
||||
t = (ragdoll.RootRigidbody.velocity.magnitude > 0.09f) ? 0 : t + Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
StartCoroutine(Restore());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 849a7739a7df0754882fcb34c09df4c1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -1,44 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ReloadSceneOnKeyDown : MonoBehaviour {
|
||||
|
||||
public KeyCode reloadKey = KeyCode.R;
|
||||
|
||||
void Update () {
|
||||
if (Input.GetKeyDown(reloadKey))
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d655607dd16c7f644a73bd10fc7370b1
|
||||
timeCreated: 1523294158
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,41 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
public class Rotator : MonoBehaviour {
|
||||
public Vector3 direction = new Vector3(0, 0, 1f);
|
||||
public float speed = 1f;
|
||||
|
||||
void Update () {
|
||||
transform.Rotate(direction * (speed * Time.deltaTime * 100f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12e291cb54756d04c9dd53ad6e00a126
|
||||
timeCreated: 1479532891
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8033179a12443e4eaef33b35fed074c
|
||||
folderAsset: yes
|
||||
timeCreated: 1495179724
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,69 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
public class OutlineSkeletonGraphic : MonoBehaviour {
|
||||
|
||||
public SkeletonGraphic skeletonGraphic;
|
||||
public Material materialWithoutOutline;
|
||||
public Material materialWithOutline;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void Reset () {
|
||||
skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
|
||||
// Add normal material as default
|
||||
if (skeletonGraphic != null && skeletonGraphic.skeletonDataAsset != null) {
|
||||
var atlasAssets = skeletonGraphic.skeletonDataAsset.atlasAssets;
|
||||
|
||||
if (atlasAssets.Length > 0 && atlasAssets[0].PrimaryMaterial) {
|
||||
materialWithoutOutline = atlasAssets[0].PrimaryMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void OnEnable () {
|
||||
if (skeletonGraphic == null)
|
||||
skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
}
|
||||
|
||||
public void EnableOutlineRendering () {
|
||||
skeletonGraphic.material = materialWithOutline;
|
||||
}
|
||||
|
||||
public void DisableOutlineRendering () {
|
||||
skeletonGraphic.material = materialWithoutOutline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78ceaa27e3b3c27498dcdd7729ebad83
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,152 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
[ExecuteAlways]
|
||||
#else
|
||||
[ExecuteInEditMode]
|
||||
#endif
|
||||
[RequireComponent(typeof(MeshRenderer)), RequireComponent(typeof(MeshFilter))]
|
||||
public class RenderExistingMesh : MonoBehaviour
|
||||
{
|
||||
public MeshRenderer referenceRenderer;
|
||||
|
||||
bool updateViaSkeletonCallback = false;
|
||||
MeshFilter referenceMeshFilter;
|
||||
MeshRenderer ownRenderer;
|
||||
MeshFilter ownMeshFilter;
|
||||
|
||||
[System.Serializable]
|
||||
public struct MaterialReplacement {
|
||||
public Material originalMaterial;
|
||||
public Material replacementMaterial;
|
||||
}
|
||||
public MaterialReplacement[] replacementMaterials = new MaterialReplacement[0];
|
||||
|
||||
private Dictionary<Material, Material> replacementMaterialDict = new Dictionary<Material, Material>();
|
||||
private Material[] sharedMaterials = new Material[0];
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Reset () {
|
||||
if (referenceRenderer == null) {
|
||||
referenceRenderer = this.transform.parent.GetComponentInParent<MeshRenderer>();
|
||||
if (!referenceRenderer)
|
||||
return;
|
||||
}
|
||||
|
||||
var parentMaterials = referenceRenderer.sharedMaterials;
|
||||
if (replacementMaterials.Length != parentMaterials.Length) {
|
||||
replacementMaterials = new MaterialReplacement[parentMaterials.Length];
|
||||
}
|
||||
for (int i = 0; i < parentMaterials.Length; ++i) {
|
||||
replacementMaterials[i].originalMaterial = parentMaterials[i];
|
||||
replacementMaterials[i].replacementMaterial = parentMaterials[i];
|
||||
}
|
||||
Awake();
|
||||
LateUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
void Awake () {
|
||||
if (referenceRenderer == null) {
|
||||
referenceRenderer = this.transform.parent.GetComponentInParent<MeshRenderer>();
|
||||
}
|
||||
|
||||
// subscribe to OnMeshAndMaterialsUpdated
|
||||
var skeletonRenderer = referenceRenderer.GetComponent<SkeletonAnimation>();
|
||||
if (skeletonRenderer) {
|
||||
skeletonRenderer.OnMeshAndMaterialsUpdated -= UpdateOnCallback;
|
||||
skeletonRenderer.OnMeshAndMaterialsUpdated += UpdateOnCallback;
|
||||
updateViaSkeletonCallback = true;
|
||||
}
|
||||
referenceMeshFilter = referenceRenderer.GetComponent<MeshFilter>();
|
||||
ownRenderer = this.GetComponent<MeshRenderer>();
|
||||
ownMeshFilter = this.GetComponent<MeshFilter>();
|
||||
|
||||
InitializeDict();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Update () {
|
||||
if (!Application.isPlaying) {
|
||||
InitializeDict();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void LateUpdate () {
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) {
|
||||
UpdateMaterials();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (updateViaSkeletonCallback)
|
||||
return;
|
||||
UpdateMaterials();
|
||||
}
|
||||
|
||||
void UpdateOnCallback (SkeletonRenderer r) {
|
||||
UpdateMaterials();
|
||||
}
|
||||
|
||||
void UpdateMaterials () {
|
||||
ownMeshFilter.sharedMesh = referenceMeshFilter.sharedMesh;
|
||||
|
||||
var parentMaterials = referenceRenderer.sharedMaterials;
|
||||
if (sharedMaterials.Length != parentMaterials.Length) {
|
||||
sharedMaterials = new Material[parentMaterials.Length];
|
||||
}
|
||||
for (int i = 0; i < parentMaterials.Length; ++i) {
|
||||
var parentMaterial = parentMaterials[i];
|
||||
if (replacementMaterialDict.ContainsKey(parentMaterial)) {
|
||||
sharedMaterials[i] = replacementMaterialDict[parentMaterial];
|
||||
}
|
||||
}
|
||||
ownRenderer.sharedMaterials = sharedMaterials;
|
||||
}
|
||||
|
||||
void InitializeDict () {
|
||||
for (int i = 0; i < replacementMaterials.Length; ++i) {
|
||||
var entry = replacementMaterials[i];
|
||||
replacementMaterialDict[entry.originalMaterial] = entry.replacementMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbb58643468d3dc479e20aff7c8c611e
|
||||
timeCreated: 1585240369
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,48 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
public class RootMotionDeltaCompensation : MonoBehaviour {
|
||||
|
||||
[SerializeField] protected SkeletonRootMotionBase rootMotion;
|
||||
public Transform targetPosition;
|
||||
public int trackIndex = 0;
|
||||
public bool adjustX = true;
|
||||
public bool adjustY = true;
|
||||
public float minScaleX = -999;
|
||||
public float minScaleY = -999;
|
||||
public float maxScaleX = 999;
|
||||
public float maxScaleY = 999;
|
||||
|
||||
public bool allowXTranslation = false;
|
||||
public bool allowYTranslation = true;
|
||||
|
||||
void Start () {
|
||||
if (rootMotion == null)
|
||||
rootMotion = this.GetComponent<SkeletonRootMotionBase>();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
AdjustDelta();
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
if (adjustX)
|
||||
rootMotion.rootMotionScaleX = 1;
|
||||
if (adjustY)
|
||||
rootMotion.rootMotionScaleY = 1;
|
||||
if (allowXTranslation)
|
||||
rootMotion.rootMotionTranslateXPerY = 0;
|
||||
if (allowYTranslation)
|
||||
rootMotion.rootMotionTranslateYPerX = 0;
|
||||
}
|
||||
|
||||
void AdjustDelta() {
|
||||
Vector3 toTarget = targetPosition.position - this.transform.position;
|
||||
rootMotion.AdjustRootMotionToDistance(toTarget, trackIndex, adjustX, adjustY,
|
||||
minScaleX, maxScaleX, minScaleY, maxScaleY,
|
||||
allowXTranslation, allowYTranslation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e47cc991328826946a8c4efdd1885bf2
|
||||
timeCreated: 1599066046
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,84 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Spine.Unity.Examples {
|
||||
|
||||
// This is a sample component for C# vertex effects for Spine rendering components.
|
||||
// Using shaders and materials to control vertex properties is still more performant
|
||||
// than using this API, but in cases where your vertex effect logic cannot be
|
||||
// expressed as shader code, these vertex effects can be useful.
|
||||
public class JitterEffectExample : MonoBehaviour {
|
||||
|
||||
[Range(0f, 0.8f)]
|
||||
public float jitterMagnitude = 0.2f;
|
||||
|
||||
SkeletonRenderer skeletonRenderer;
|
||||
|
||||
void OnEnable () {
|
||||
skeletonRenderer = GetComponent<SkeletonRenderer>();
|
||||
if (skeletonRenderer == null) return;
|
||||
|
||||
// Use the OnPostProcessVertices callback to modify the vertices at the correct time.
|
||||
skeletonRenderer.OnPostProcessVertices -= ProcessVertices;
|
||||
skeletonRenderer.OnPostProcessVertices += ProcessVertices;
|
||||
|
||||
Debug.Log("Jitter Effect Enabled.");
|
||||
}
|
||||
|
||||
void ProcessVertices (MeshGeneratorBuffers buffers) {
|
||||
if (!this.enabled) return;
|
||||
|
||||
// For efficiency, limit your effect to the actual mesh vertex count using vertexCount
|
||||
int vertexCount = buffers.vertexCount;
|
||||
|
||||
// Modify vertex positions by accessing Vector3[] vertexBuffer
|
||||
var vertices = buffers.vertexBuffer;
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
vertices[i] += (Vector3)(Random.insideUnitCircle * jitterMagnitude);
|
||||
|
||||
// You can also modify uvs and colors.
|
||||
//var uvs = buffers.uvBuffer;
|
||||
//var colors = buffers.colorBuffer;
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
if (skeletonRenderer == null) return;
|
||||
skeletonRenderer.OnPostProcessVertices -= ProcessVertices;
|
||||
|
||||
Debug.Log("Jitter Effect Disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b9ca76eac8062f42b99bbf78e777ee1
|
||||
timeCreated: 1498053868
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user