Noeski

Hey there,

Is there any way to use [SpineSlot] to select from a list of slots on a Skeleton without the actual component/game object? I'd like to be able to use this on some ScriptableObjects that are used for attachments and it would be nice to not have to enter them by hand if possible!
Noeski
Posts: 5

Pharan

Yes. You'd define your ScriptableObject like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Spine;
using Spine.Unity;

namespace Spine.Unity.Examples {
[CreateAssetMenu(menuName = "My Sample Asset Thing")]
public class SampleSkeletonAsset : ScriptableObject, IHasSkeletonDataAsset {

public SkeletonDataAsset skeletonDataAsset;

// The IHasSkeletonDataAsset interface allows all your attributes to recognize the data source.
public SkeletonDataAsset SkeletonDataAsset {
get { return skeletonDataAsset; }
}

[SpineSlot] // this will know it is an IHasSkeletonDataAsset
public string mySlot;

[SpineSkin]
public string mySkin;

[SpineAttachment(skinField = "mySkin", slotField = "mySlot")]
public string myAttachment;

// If you have multiple, or don't want to define IHasSkeletonDataAsset,
// you can always specify which skeletonDataAsset field to use through dataField.
[SpineSlot(dataField = "skeletonDataAsset")]
public string mySecondSlot;


// ... Methods and Stuff...
}
}
User avatar
Pharan

Pharan
Posts: 5015

Noeski

Amazing, thank you!

The only problem is that I'd like to not have to serialize a reference to the asset for each ScriptableObject and purely use it as an editing tool.. but not sure if that is possible without some Editor extensions?
Noeski
Posts: 5

Pharan

So you want to serialize the names of slots but not associate it with the SkeletonDataAsset it belongs to?

I don't think we have anything out of the box that does that. You'll have to write your own editor code for it.
User avatar
Pharan

Pharan
Posts: 5015


Return to Unity