mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-13 02:28:44 +08:00
[unity] SkeletonGraphic runtime instantiation requires Material.
This commit is contained in:
parent
aa0dcee09a
commit
495321e6af
@ -106,16 +106,21 @@ namespace Spine.Unity {
|
||||
#endregion
|
||||
|
||||
#region Runtime Instantiation
|
||||
public static SkeletonGraphic NewSkeletonGraphicGameObject (SkeletonDataAsset skeletonDataAsset, Transform parent) {
|
||||
SkeletonGraphic sg = SkeletonGraphic.AddSkeletonGraphicComponent(new GameObject("New Spine GameObject"), skeletonDataAsset);
|
||||
/// <summary>Create a new GameObject with a SkeletonGraphic component.</summary>
|
||||
/// <param name="material">Material for the canvas renderer to use. Usually, the default SkeletonGraphic material will work.</param>
|
||||
public static SkeletonGraphic NewSkeletonGraphicGameObject (SkeletonDataAsset skeletonDataAsset, Transform parent, Material material) {
|
||||
var sg = SkeletonGraphic.AddSkeletonGraphicComponent(new GameObject("New Spine GameObject"), skeletonDataAsset, material);
|
||||
if (parent != null) sg.transform.SetParent(parent, false);
|
||||
return sg;
|
||||
}
|
||||
|
||||
public static SkeletonGraphic AddSkeletonGraphicComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset) {
|
||||
/// <summary>Add a SkeletonGraphic component to a GameObject.</summary>
|
||||
/// <param name="material">Material for the canvas renderer to use. Usually, the default SkeletonGraphic material will work.</param>
|
||||
public static SkeletonGraphic AddSkeletonGraphicComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset, Material material) {
|
||||
var c = gameObject.AddComponent<SkeletonGraphic>();
|
||||
if (skeletonDataAsset != null) {
|
||||
c.skeletonDataAsset = skeletonDataAsset;
|
||||
c.material = material;
|
||||
c.skeletonDataAsset = skeletonDataAsset;
|
||||
c.Initialize(false);
|
||||
}
|
||||
return c;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user