mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[Unity] Allow SkeletonGhost use in camera distance sorting setup.
This commit is contained in:
parent
bfb58cbb19
commit
64f69343a2
@ -11,7 +11,7 @@ using System.Collections.Generic;
|
|||||||
public class SkeletonGhost : MonoBehaviour {
|
public class SkeletonGhost : MonoBehaviour {
|
||||||
public bool ghostingEnabled = true;
|
public bool ghostingEnabled = true;
|
||||||
public float spawnRate = 0.05f;
|
public float spawnRate = 0.05f;
|
||||||
public Color32 color = new Color32(0xFF, 0xFF, 0xFF, 0x00);
|
public Color32 color = new Color32(0xFF, 0xFF, 0xFF, 0x00); // default for additive.
|
||||||
[Tooltip("Remember to set color alpha to 0 if Additive is true")]
|
[Tooltip("Remember to set color alpha to 0 if Additive is true")]
|
||||||
public bool additive = true;
|
public bool additive = true;
|
||||||
public int maximumGhosts = 10;
|
public int maximumGhosts = 10;
|
||||||
@ -21,6 +21,10 @@ public class SkeletonGhost : MonoBehaviour {
|
|||||||
[Range(0, 1)]
|
[Range(0, 1)]
|
||||||
public float textureFade = 1;
|
public float textureFade = 1;
|
||||||
|
|
||||||
|
[Header("Sorting")]
|
||||||
|
public bool sortWithDistanceOnly;
|
||||||
|
public float zOffset = 0f;
|
||||||
|
|
||||||
float nextSpawnTime;
|
float nextSpawnTime;
|
||||||
SkeletonGhostRenderer[] pool;
|
SkeletonGhostRenderer[] pool;
|
||||||
int poolIndex = 0;
|
int poolIndex = 0;
|
||||||
@ -100,14 +104,16 @@ public class SkeletonGhost : MonoBehaviour {
|
|||||||
materials[i] = ghostMat;
|
materials[i] = ghostMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
pool[poolIndex].Initialize(meshFilter.sharedMesh, materials, color, additive, fadeSpeed, meshRenderer.sortingOrder - 1);
|
var goTransform = go.transform;
|
||||||
go.transform.parent = transform;
|
goTransform.parent = transform;
|
||||||
|
|
||||||
go.transform.localPosition = Vector3.zero;
|
pool[poolIndex].Initialize(meshFilter.sharedMesh, materials, color, additive, fadeSpeed, meshRenderer.sortingLayerID, (sortWithDistanceOnly) ? meshRenderer.sortingOrder : meshRenderer.sortingOrder - 1);
|
||||||
go.transform.localRotation = Quaternion.identity;
|
|
||||||
go.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
go.transform.parent = null;
|
goTransform.localPosition = new Vector3(0f, 0f, zOffset);
|
||||||
|
goTransform.localRotation = Quaternion.identity;
|
||||||
|
goTransform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
goTransform.parent = null;
|
||||||
|
|
||||||
poolIndex++;
|
poolIndex++;
|
||||||
|
|
||||||
|
|||||||
@ -20,13 +20,14 @@ public class SkeletonGhostRenderer : MonoBehaviour {
|
|||||||
meshFilter = gameObject.AddComponent<MeshFilter>();
|
meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize (Mesh mesh, Material[] materials, Color32 color, bool additive, float speed, int sortingOrder) {
|
public void Initialize (Mesh mesh, Material[] materials, Color32 color, bool additive, float speed, int sortingLayerID, int sortingOrder) {
|
||||||
StopAllCoroutines();
|
StopAllCoroutines();
|
||||||
|
|
||||||
gameObject.SetActive(true);
|
gameObject.SetActive(true);
|
||||||
|
|
||||||
|
|
||||||
meshRenderer.sharedMaterials = materials;
|
meshRenderer.sharedMaterials = materials;
|
||||||
|
meshRenderer.sortingLayerID = sortingLayerID;
|
||||||
meshRenderer.sortingOrder = sortingOrder;
|
meshRenderer.sortingOrder = sortingOrder;
|
||||||
|
|
||||||
meshFilter.sharedMesh = (Mesh)Instantiate(mesh);
|
meshFilter.sharedMesh = (Mesh)Instantiate(mesh);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user