public static NewPartsRendererGameObject ( |
||
parent | ||
name | string | |
return |
/// <summary>Add a child SkeletonPartsRenderer GameObject to this SkeletonRenderSeparator.</summary> public SkeletonPartsRenderer AddPartsRenderer(int sortingOrderIncrement = DefaultSortingOrderIncrement, string name = null) { int sortingLayerID = 0; int sortingOrder = 0; if (partsRenderers.Count > 0) { var previous = partsRenderers[partsRenderers.Count - 1]; var previousMeshRenderer = previous.MeshRenderer; sortingLayerID = previousMeshRenderer.sortingLayerID; sortingOrder = previousMeshRenderer.sortingOrder + sortingOrderIncrement; } if (string.IsNullOrEmpty(name)) { name = partsRenderers.Count.ToString(); } var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRenderer.transform, name); partsRenderers.Add(spr); var mr = spr.MeshRenderer; mr.sortingLayerID = sortingLayerID; mr.sortingOrder = sortingOrder; return(spr); }
/// <summary>Adds a SkeletonRenderSeparator and child SkeletonPartsRenderer GameObjects to a given SkeletonRenderer.</summary> /// <returns>The to skeleton renderer.</returns> /// <param name="skeletonRenderer">The target SkeletonRenderer or SkeletonAnimation.</param> /// <param name="sortingLayerID">Sorting layer to be used for the parts renderers.</param> /// <param name="extraPartsRenderers">Number of additional SkeletonPartsRenderers on top of the ones determined by counting the number of separator slots.</param> /// <param name="sortingOrderIncrement">The integer to increment the sorting order per SkeletonPartsRenderer to separate them.</param> /// <param name="baseSortingOrder">The sorting order value of the first SkeletonPartsRenderer.</param> /// <param name="addMinimumPartsRenderers">If set to <c>true</c>, a minimum number of SkeletonPartsRenderer GameObjects (determined by separatorSlots.Count + 1) will be added.</param> public static SkeletonRenderSeparator AddToSkeletonRenderer(SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = DefaultSortingOrderIncrement, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) { if (skeletonRenderer == null) { Debug.Log("Tried to add SkeletonRenderSeparator to a null SkeletonRenderer reference."); return(null); } var srs = skeletonRenderer.gameObject.AddComponent <SkeletonRenderSeparator>(); srs.skeletonRenderer = skeletonRenderer; skeletonRenderer.Initialize(false); int count = extraPartsRenderers; if (addMinimumPartsRenderers) { count = extraPartsRenderers + skeletonRenderer.separatorSlots.Count + 1; } var skeletonRendererTransform = skeletonRenderer.transform; var componentRenderers = srs.partsRenderers; for (int i = 0; i < count; i++) { var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRendererTransform, i.ToString()); var mr = spr.MeshRenderer; mr.sortingLayerID = sortingLayerID; mr.sortingOrder = baseSortingOrder + (i * sortingOrderIncrement); componentRenderers.Add(spr); } return(srs); }
public static SkeletonRenderSeparator AddToSkeletonRenderer(Spine.Unity.SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = 5, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) { if (skeletonRenderer == null) { Debug.Log("Tried to add SkeletonRenderSeparator to a null SkeletonRenderer reference."); return(null); } SkeletonRenderSeparator separator = skeletonRenderer.gameObject.AddComponent <SkeletonRenderSeparator>(); separator.skeletonRenderer = skeletonRenderer; skeletonRenderer.Initialize(false); int num = extraPartsRenderers; if (addMinimumPartsRenderers) { num = (extraPartsRenderers + skeletonRenderer.separatorSlots.Count) + 1; } Transform parent = skeletonRenderer.transform; List <SkeletonPartsRenderer> partsRenderers = separator.partsRenderers; for (int i = 0; i < num; i++) { SkeletonPartsRenderer item = SkeletonPartsRenderer.NewPartsRendererGameObject(parent, i.ToString()); MeshRenderer meshRenderer = item.MeshRenderer; meshRenderer.sortingLayerID = sortingLayerID; meshRenderer.sortingOrder = baseSortingOrder + (i * sortingOrderIncrement); partsRenderers.Add(item); } return(separator); }
public static SkeletonRenderSeparator AddToSkeletonRenderer(SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = 5, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) { if (skeletonRenderer == null) { return(null); } SkeletonRenderSeparator skeletonRenderSeparator = skeletonRenderer.gameObject.AddComponent <SkeletonRenderSeparator>(); skeletonRenderSeparator.skeletonRenderer = skeletonRenderer; skeletonRenderer.Initialize(overwrite: false); int num = extraPartsRenderers; if (addMinimumPartsRenderers) { num = extraPartsRenderers + skeletonRenderer.separatorSlots.Count + 1; } Transform transform = skeletonRenderer.transform; List <SkeletonPartsRenderer> list = skeletonRenderSeparator.partsRenderers; for (int i = 0; i < num; i++) { SkeletonPartsRenderer skeletonPartsRenderer = SkeletonPartsRenderer.NewPartsRendererGameObject(transform, i.ToString()); MeshRenderer meshRenderer = skeletonPartsRenderer.MeshRenderer; meshRenderer.sortingLayerID = sortingLayerID; meshRenderer.sortingOrder = baseSortingOrder + i * sortingOrderIncrement; list.Add(skeletonPartsRenderer); } return(skeletonRenderSeparator); }
/// <summary>Adds a SkeletonRenderSeparator and child SkeletonPartsRenderer GameObjects to a given SkeletonRenderer.</summary> /// <returns>The to skeleton renderer.</returns> /// <param name="skeletonRenderer">The target SkeletonRenderer or SkeletonAnimation.</param> /// <param name="sortingLayerID">Sorting layer to be used for the parts renderers.</param> /// <param name="extraPartsRenderers">Number of additional SkeletonPartsRenderers on top of the ones determined by counting the number of separator slots.</param> /// <param name="sortingOrderIncrement">The integer to increment the sorting order per SkeletonPartsRenderer to separate them.</param> /// <param name="baseSortingOrder">The sorting order value of the first SkeletonPartsRenderer.</param> /// <param name="addMinimumPartsRenderers">If set to <c>true</c>, a minimum number of SkeletonPartsRenderer GameObjects (determined by separatorSlots.Count + 1) will be added.</param> public static SkeletonRenderSeparator AddToSkeletonRenderer(SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = DefaultSortingOrderIncrement, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) { if (skeletonRenderer == null) { Debug.Log("Tried to add SkeletonRenderSeparator to a null SkeletonRenderer reference."); return(null); } var srs = skeletonRenderer.gameObject.AddComponent <SkeletonRenderSeparator>(); srs.skeletonRenderer = skeletonRenderer; skeletonRenderer.Initialize(false); int count = extraPartsRenderers; if (addMinimumPartsRenderers) { count = extraPartsRenderers + skeletonRenderer.separatorSlots.Count + 1; } var skeletonRendererTransform = skeletonRenderer.transform; var componentRenderers = srs.partsRenderers; for (int i = 0; i < count; i++) { var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRendererTransform, i.ToString()); var mr = spr.MeshRenderer; mr.sortingLayerID = sortingLayerID; mr.sortingOrder = baseSortingOrder + (i * sortingOrderIncrement); componentRenderers.Add(spr); } srs.OnEnable(); #if UNITY_EDITOR // Make sure editor updates properly in edit mode. if (!Application.isPlaying) { skeletonRenderer.enabled = false; skeletonRenderer.enabled = true; skeletonRenderer.LateUpdate(); } #endif return(srs); }
public void AddPartsRenderer(int count) { var componentRenderers = component.partsRenderers; bool emptyFound = componentRenderers.Contains(null); if (emptyFound) { bool userClearEntries = EditorUtility.DisplayDialog("Empty entries found", "Null entries found. Do you want to remove null entries before adding the new renderer? ", "Clear Empty Entries", "Don't Clear"); if (userClearEntries) { componentRenderers.RemoveAll(x => x == null); } } Undo.RegisterCompleteObjectUndo(component, "Add Parts Renderers"); for (int i = 0; i < count; i++) { int index = componentRenderers.Count; var smr = SkeletonPartsRenderer.NewPartsRendererGameObject(component.transform, index.ToString()); Undo.RegisterCreatedObjectUndo(smr.gameObject, "New Parts Renderer GameObject."); componentRenderers.Add(smr); // increment renderer sorting order. if (index == 0) { continue; } var prev = componentRenderers[index - 1]; if (prev == null) { continue; } var prevMeshRenderer = prev.GetComponent <MeshRenderer>(); var currentMeshRenderer = smr.GetComponent <MeshRenderer>(); if (prevMeshRenderer == null || currentMeshRenderer == null) { continue; } int prevSortingLayer = prevMeshRenderer.sortingLayerID; int prevSortingOrder = prevMeshRenderer.sortingOrder; currentMeshRenderer.sortingLayerID = prevSortingLayer; currentMeshRenderer.sortingOrder = prevSortingOrder + SkeletonRenderSeparator.DefaultSortingOrderIncrement; } }
public void AddPartsRenderer(int sortingOrderIncrement = 5) { int sortingLayerID = 0; int num2 = 0; if (this.partsRenderers.Count > 0) { SkeletonPartsRenderer renderer = this.partsRenderers[this.partsRenderers.Count - 1]; MeshRenderer renderer2 = renderer.MeshRenderer; sortingLayerID = renderer2.sortingLayerID; num2 = renderer2.sortingOrder + sortingOrderIncrement; } SkeletonPartsRenderer item = SkeletonPartsRenderer.NewPartsRendererGameObject(this.skeletonRenderer.transform, this.partsRenderers.Count.ToString()); this.partsRenderers.Add(item); MeshRenderer meshRenderer = item.MeshRenderer; meshRenderer.sortingLayerID = sortingLayerID; meshRenderer.sortingOrder = num2; }
public void AddPartsRenderer(int sortingOrderIncrement = 5) { int sortingLayerID = 0; int sortingOrder = 0; if (partsRenderers.Count > 0) { SkeletonPartsRenderer skeletonPartsRenderer = partsRenderers[partsRenderers.Count - 1]; MeshRenderer meshRenderer = skeletonPartsRenderer.MeshRenderer; sortingLayerID = meshRenderer.sortingLayerID; sortingOrder = meshRenderer.sortingOrder + sortingOrderIncrement; } SkeletonPartsRenderer skeletonPartsRenderer2 = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRenderer.transform, partsRenderers.Count.ToString()); partsRenderers.Add(skeletonPartsRenderer2); MeshRenderer meshRenderer2 = skeletonPartsRenderer2.MeshRenderer; meshRenderer2.sortingLayerID = sortingLayerID; meshRenderer2.sortingOrder = sortingOrder; }
/// <summary>Add a child SkeletonPartsRenderer GameObject to this SkeletonRenderSeparator.</summary> public void AddPartsRenderer(int sortingOrderIncrement = DefaultSortingOrderIncrement) { int sortingLayerID = 0; int sortingOrder = 0; if (partsRenderers.Count > 0) { var previous = partsRenderers[partsRenderers.Count - 1]; var previousMeshRenderer = previous.MeshRenderer; sortingLayerID = previousMeshRenderer.sortingLayerID; sortingOrder = previousMeshRenderer.sortingOrder + sortingOrderIncrement; } var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRenderer.transform, partsRenderers.Count.ToString()); partsRenderers.Add(spr); var mr = spr.MeshRenderer; mr.sortingLayerID = sortingLayerID; mr.sortingOrder = sortingOrder; }