概要
2017年6月15日のお話。
UnityでSpineを動かすには、Unity内にSpineのランタイムを入れる必要があります。
しかし、古いUnityの場合ちゃんとSpineのランタイムが動かないのですが、それを動かす方法の備忘録。
作業内容
まず、普通にspine-csharpとspine-unityを入れます。
すると、次の内容で文句を言われます。
Assets/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs(381,33): error CS1502: The best overloaded method match for UnityEditor.MaterialEditor.ShaderProperty(UnityEditor.MaterialProperty, string)' has some invalid arguments
Assets/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs(381,33): error CS1503: Argument #2′ cannot convert UnityEngine.GUIContent' expression to type string’
Assets/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs(659,41): error CS1502: The best overloaded method match for UnityEditor.MaterialEditor.ShaderProperty(UnityEditor.MaterialProperty, string, int)' has some invalid arguments
Assets/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs(659,41): error CS1503: Argument #2′ cannot convert UnityEngine.GUIContent' expression to type string’
要は、UnityEditor.MaterialEditor.ShaderPropertyがstring型じゃないぜ、コンバートもできないぜ!っていう内容です。
開発者の意図としてあっているかは不明ですが、UnityEngine.GUIContentにはtextという属性がありますので、単にそれを指定してやれば解決します。
SpineSpriteShaderGUI.csの381行目
古 : _materialEditor.ShaderProperty(_pixelSnap, _pixelSnapText);
新 : _materialEditor.ShaderProperty(_pixelSnap, _pixelSnapText.text.text);
SpineSpriteShaderGUI.csの659行目
古 : _materialEditor.ShaderProperty(hasGlossMap ? _smoothnessScale : _smoothness, hasGlossMap ? _smoothnessScaleText : _smoothnessText, indentation);
新 : _materialEditor.ShaderProperty(hasGlossMap ? _smoothnessScale : _smoothness, hasGlossMap ? _smoothnessScaleText.text : _smoothnessText.text, indentation);
以上