Inheritance: UnityEngine.MonoBehaviour
        /// <summary>Detects orphaned parts renderers and offers to delete them.</summary>
        public void DetectOrphanedPartsRenderers(SkeletonRenderSeparator component)
        {
            var children = component.GetComponentsInChildren <SkeletonPartsRenderer>();

            var orphans = new System.Collections.Generic.List <SkeletonPartsRenderer>();

            foreach (var r in children)
            {
                if (!component.partsRenderers.Contains(r))
                {
                    orphans.Add(r);
                }
            }

            if (orphans.Count > 0)
            {
                if (EditorUtility.DisplayDialog("Destroy Submesh Renderers", "Unassigned renderers were found. Do you want to delete them? (These may belong to another Render Separator in the same hierarchy. If you don't have another Render Separator component in the children of this GameObject, it's likely safe to delete. Warning: This operation cannot be undone.)", "Delete", "Cancel"))
                {
                    foreach (var o in orphans)
                    {
                        DestroyImmediate(o.gameObject, allowDestroyingAssets: false);
                    }
                }
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
		void OnEnable () {
			if (component == null)
				component = target as SkeletonRenderSeparator;

			skeletonRenderer_ = serializedObject.FindProperty("skeletonRenderer");
			copyPropertyBlock_ = serializedObject.FindProperty("copyPropertyBlock");
			copyMeshRendererFlags_ = serializedObject.FindProperty("copyMeshRendererFlags");

			var partsRenderers = component.partsRenderers;
			partsRenderers_ = serializedObject.FindProperty("partsRenderers");
			partsRenderers_.isExpanded = partsRenderersExpanded ||	// last state
				partsRenderers.Contains(null) ||	// null items found
				partsRenderers.Count < 1 ||			// no parts renderers
				(skeletonRenderer_.objectReferenceValue != null && SkeletonRendererSeparatorCount + 1 > partsRenderers.Count); // not enough parts renderers
		}
        void OnEnable()
        {
            if (component == null)
            {
                component = target as SkeletonRenderSeparator;
            }

            skeletonRenderer_      = serializedObject.FindProperty("skeletonRenderer");
            copyPropertyBlock_     = serializedObject.FindProperty("copyPropertyBlock");
            copyMeshRendererFlags_ = serializedObject.FindProperty("copyMeshRendererFlags");

            var partsRenderers = component.partsRenderers;

            partsRenderers_            = serializedObject.FindProperty("partsRenderers");
            partsRenderers_.isExpanded = partsRenderersExpanded ||                                                                                      // last state
                                         partsRenderers.Contains(null) ||                                                                               // null items found
                                         partsRenderers.Count < 1 ||                                                                                    // no parts renderers
                                         (skeletonRenderer_.objectReferenceValue != null && SkeletonRendererSeparatorCount + 1 > partsRenderers.Count); // not enough parts renderers
        }
		/// <summary>Detects orphaned parts renderers and offers to delete them.</summary>
		public void DetectOrphanedPartsRenderers (SkeletonRenderSeparator component) {
			var children = component.GetComponentsInChildren<SkeletonPartsRenderer>();

			var orphans = new System.Collections.Generic.List<SkeletonPartsRenderer>();
			foreach (var r in children) {
				if (!component.partsRenderers.Contains(r))
					orphans.Add(r);
			}

			if (orphans.Count > 0) {
				if (EditorUtility.DisplayDialog("Destroy Submesh Renderers", "Unassigned renderers were found. Do you want to delete them? (These may belong to another Render Separator in the same hierarchy. If you don't have another Render Separator component in the children of this GameObject, it's likely safe to delete. Warning: This operation cannot be undone.)", "Delete", "Cancel")) {
					foreach (var o in orphans) {
						DestroyImmediate(o.gameObject, allowDestroyingAssets: false);
					}
				}
			}
		}