From 5d22bef460b372f3fc746a6e938de1ac32a9028b Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 7 Nov 2016 21:29:49 +0800 Subject: [PATCH] [unity] Some cleanup. --- ...ttachmentUtility.cs => AttachmentTools.cs} | 37 ++++++++-- ...tility.cs.meta => AttachmentTools.cs.meta} | 0 ...xt => SkeletonRendererCustomMaterials.txt} | 0 ... SkeletonRendererCustomMaterials.txt.meta} | 0 ...SkeletonUtilitySubmeshRendererInspector.cs | 49 ------------- ...tonUtilitySubmeshRendererInspector.cs.meta | 8 --- .../SkeletonUtilitySubmeshRenderer.cs | 71 ------------------- .../SkeletonUtilitySubmeshRenderer.cs.meta | 14 ---- 8 files changed, 32 insertions(+), 147 deletions(-) rename spine-unity/Assets/spine-unity/Modules/AttachmentTools/{AttachmentUtility.cs => AttachmentTools.cs} (95%) rename spine-unity/Assets/spine-unity/Modules/AttachmentTools/{AttachmentUtility.cs.meta => AttachmentTools.cs.meta} (100%) rename spine-unity/Assets/spine-unity/Modules/CustomMaterials/{readme.txt => SkeletonRendererCustomMaterials.txt} (100%) rename spine-unity/Assets/spine-unity/Modules/CustomMaterials/{readme.txt.meta => SkeletonRendererCustomMaterials.txt.meta} (100%) delete mode 100644 spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs delete mode 100644 spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs.meta delete mode 100644 spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs delete mode 100644 spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs.meta diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentUtility.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs similarity index 95% rename from spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentUtility.cs rename to spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index d60f8fbab..a3739c491 100644 --- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentUtility.cs +++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -33,17 +33,43 @@ using System.Collections.Generic; namespace Spine.Unity.Modules.AttachmentTools { public static class AttachmentRegionExtensions { + #region Get + /// + /// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null. + public static AtlasRegion GetRegion (this Attachment attachment) { + var regionAttachment = attachment as RegionAttachment; + if (regionAttachment != null) + return regionAttachment.RendererObject as AtlasRegion; + + var meshAttachment = attachment as MeshAttachment; + if (meshAttachment != null) + return meshAttachment.RendererObject as AtlasRegion; + + return null; + } + + /// Gets the region (image) of a RegionAttachment + public static AtlasRegion GetRegion (this RegionAttachment regionAttachment) { + return regionAttachment.RendererObject as AtlasRegion; + } + + /// Gets the region (image) of a MeshAttachment + public static AtlasRegion GetRegion (this MeshAttachment meshAttachment) { + return meshAttachment.RendererObject as AtlasRegion; + } + #endregion + + #region Set /// /// Tries to set the region (image) of a renderable attachment. If the attachment is not renderable, nothing is applied. public static void SetRegion (this Attachment attachment, AtlasRegion region, bool updateOffset = true) { var regionAttachment = attachment as RegionAttachment; - if (regionAttachment != null) { + if (regionAttachment != null) regionAttachment.SetRegion(region, updateOffset); - } else { - var meshAttachment = attachment as MeshAttachment; - if (meshAttachment != null) + + var meshAttachment = attachment as MeshAttachment; + if (meshAttachment != null) meshAttachment.SetRegion(region, updateOffset); - } } /// Sets the region (image) of a RegionAttachment @@ -83,6 +109,7 @@ namespace Spine.Unity.Modules.AttachmentTools { if (updateUVs) attachment.UpdateUVs(); } + #endregion #region Runtime RegionAttachments /// diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentUtility.cs.meta b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs.meta similarity index 100% rename from spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentUtility.cs.meta rename to spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs.meta diff --git a/spine-unity/Assets/spine-unity/Modules/CustomMaterials/readme.txt b/spine-unity/Assets/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.txt similarity index 100% rename from spine-unity/Assets/spine-unity/Modules/CustomMaterials/readme.txt rename to spine-unity/Assets/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.txt diff --git a/spine-unity/Assets/spine-unity/Modules/CustomMaterials/readme.txt.meta b/spine-unity/Assets/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.txt.meta similarity index 100% rename from spine-unity/Assets/spine-unity/Modules/CustomMaterials/readme.txt.meta rename to spine-unity/Assets/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.txt.meta diff --git a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs b/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs deleted file mode 100644 index 979e62455..000000000 --- a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF - * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using UnityEngine; -using UnityEditor; -using Spine.Unity.Editor; - -namespace Spine.Unity.Modules { - [CustomEditor(typeof(SkeletonUtilitySubmeshRenderer))] - public class SkeletonUtilitySubmeshRendererInspector : UnityEditor.Editor { - public SpineInspectorUtility.SerializedSortingProperties sorting; - - void OnEnable () { - sorting = new SpineInspectorUtility.SerializedSortingProperties((target as Component).GetComponent()); - } - - public override void OnInspectorGUI () { - EditorGUILayout.HelpBox("SkeletonUtilitySubmeshRenderer is now obsolete. We recommend using SkeletonRenderSeparator.", MessageType.Info); - SpineInspectorUtility.SortingPropertyFields(sorting, true); - } - } -} diff --git a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs.meta b/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs.meta deleted file mode 100644 index 3b5bd3485..000000000 --- a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilitySubmeshRendererInspector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 67418e462bd4dc24e8c234b92f1d4d9b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs b/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs deleted file mode 100644 index 5dec4d2a7..000000000 --- a/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF - * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using UnityEngine; - -namespace Spine.Unity.Modules { - [ExecuteInEditMode] - public class SkeletonUtilitySubmeshRenderer : MonoBehaviour { - [System.NonSerialized] - public Mesh mesh; - public int submeshIndex = 0; - public Material hiddenPassMaterial; - Renderer cachedRenderer; - MeshFilter filter; - Material[] sharedMaterials; - - void Awake () { - cachedRenderer = GetComponent(); - filter = GetComponent(); - sharedMaterials = new Material[0]; - } - - public void SetMesh (Renderer parentRenderer, Mesh mesh, Material mat) { - if (cachedRenderer == null) - return; - - cachedRenderer.enabled = true; - filter.sharedMesh = mesh; - if (cachedRenderer.sharedMaterials.Length != parentRenderer.sharedMaterials.Length) { - sharedMaterials = parentRenderer.sharedMaterials; - } - - for (int i = 0; i < sharedMaterials.Length; i++) { - if (i == submeshIndex) - sharedMaterials[i] = mat; - else - sharedMaterials[i] = hiddenPassMaterial; - } - - cachedRenderer.sharedMaterials = sharedMaterials; - } - } - -} diff --git a/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs.meta b/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs.meta deleted file mode 100644 index a58d557e9..000000000 --- a/spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs.meta +++ /dev/null @@ -1,14 +0,0 @@ -fileFormatVersion: 2 -guid: 7820c1c2b0e52c6408de899d6939996e -MonoImporter: - serializedVersion: 2 - defaultReferences: - - parentRenderer: {instanceID: 0} - - mesh: {instanceID: 0} - - hiddenPassMaterial: {fileID: 2100000, guid: 43227e5adadc6f24bb4bf74b92a56fb4, - type: 2} - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: