0
Not a bug

Spin image from center only works in preview

Scriptorum 7 years ago updated 7 years ago 6

I'm trying to rotate an image about its center. On the left, the flame shows in preview, rotating about its center. On the right, the flame in gameplay, rotating around an unknown transformation point.

Image 13

Any ideas what I'm doing wrong here? Preview works as expected. I've taken a look at Card_Arrow to see how that does spinning, but I can't see what I'm doing differently.


The shader: 

shady.shader


Sprite:

Image 14


Material:

Image 15


Possibly related, I'm seeing a NullReferenceException somewhere along the way.


NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type layoutType) (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:296)
UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayout.cs:306)
UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayout.cs:293)
ShaderWeaver.SWWindowLayoutV.OnGUI () (at Assets/ShaderWeaver/Plugin/Scripts/Editor/Window/SWWindowLayoutV.cs:268)
ShaderWeaver.SWWindowMain.OnGUI () (at Assets/ShaderWeaver/Plugin/Scripts/Editor/Window/SWWindowMain.cs:283)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture
Under review

1.   The NullReferenceException you posted, you can ignore it always. It is just a unity's editor GUI issue, which will not affect using of Shader Weaver at all.

2.   I tried the shader file in Unity2017.3f3 under Windows. It works fine in play mode. Fire rotated as expected.

Pos, pivot, loopping are relative to it, but I did not see anything unusual.

Please send a minimum project with resources  to JackieLo@aliyun.com. This project should display the problem.




Sent you the files. Aside from me being on Mac, another difference between my example and the Card_Arrow flame spinner is that's a mesh, and I'm using a Sprite. When I change it to a Mesh, it spins properly in play mode.

+1
Not a bug

Solved. There is no bug here.

In the project you gave me. SW project used 'Default Sprite Asset_14' for Root node while Sprite Renderer in the scene used  'Default Sprite Asset_0' . Different Sprites' rects are totally different if they are in sheets.

To avoid it:

1. Make sure Root node and Sprite Renderer use the same Sprite.

2. Attach SWSpriteAnimation to Sprite Object. It will set rect at runtime.

Thank you! I understand now. :)