mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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
|
#endregion
|
||||||
|
|
||||||
#region Runtime Instantiation
|
#region Runtime Instantiation
|
||||||
public static SkeletonGraphic NewSkeletonGraphicGameObject (SkeletonDataAsset skeletonDataAsset, Transform parent) {
|
/// <summary>Create a new GameObject with a SkeletonGraphic component.</summary>
|
||||||
SkeletonGraphic sg = SkeletonGraphic.AddSkeletonGraphicComponent(new GameObject("New Spine GameObject"), skeletonDataAsset);
|
/// <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);
|
if (parent != null) sg.transform.SetParent(parent, false);
|
||||||
return sg;
|
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>();
|
var c = gameObject.AddComponent<SkeletonGraphic>();
|
||||||
if (skeletonDataAsset != null) {
|
if (skeletonDataAsset != null) {
|
||||||
c.skeletonDataAsset = skeletonDataAsset;
|
c.material = material;
|
||||||
|
c.skeletonDataAsset = skeletonDataAsset;
|
||||||
c.Initialize(false);
|
c.Initialize(false);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user