前提
Unityで、WebGLビルドすると、ビルドはできるのですが、画像のようなエラーがでて動かなくなります。
Unityエディターでは正常に動いています。
実現したいこと
エラーをなくして、正常に動かせるようにすること。
発生している問題・エラーメッセージ
A scripted object (probably Rotate?) has a different serialization layout when loading. (Read 32 bytes but expected 44 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
エラー文が、データを読み取れませんでした、
The referenced script (Rotate) on this Behaviour is missing!
警告文が、そんなスクリプトは存在しません、と言っているのだと思います。
C#
1using System; 2using FlutterUnityIntegration; 3using UnityEngine; 4using UnityEngine.EventSystems; 5 6public class Rotate : MonoBehaviour, IEventSystemHandler 7{ 8 [SerializeField] 9 Vector3 RotateAmount; 10 11 // Start is called before the first frame update 12 void Start() 13 { 14 RotateAmount = new Vector3(0, 0, 0); 15 } 16 17 // Update is called once per frame 18 void Update() 19 { 20 gameObject.transform.Rotate(RotateAmount * Time.deltaTime * 120); 21 22 for (int i = 0; i < Input.touchCount; ++i) 23 { 24 if (Input.GetTouch(i).phase.Equals(TouchPhase.Began)) 25 { 26 var hit = new RaycastHit(); 27 28 Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position); 29 30 if (Physics.Raycast(ray, out hit)) 31 { 32 // This method is used to send data to Flutter 33 UnityMessageManager.Instance.SendMessageToFlutter("The cube feels touched."); 34 } 35 } 36 } 37 } 38 39 // This method is called from Flutter 40 public void SetRotationSpeed(String message) 41 { 42 float value = float.Parse(message); 43 RotateAmount = new Vector3(value, value, value); 44 } 45}
試したこと
Unityで正常動作確認できているシーンをWebGLビルドして、進行不能になりました。
補足情報(FW/ツールのバージョンなど)
Unity:2022.1.7 (このブランチで2021.1.28から上げました)
原因は、Unityのバージョンを2022.1.7に上げた際に何かが剥がれたのかなーと思ってます。
何かこのエラーでわかる方がいれば、教えて頂きたいです!
※CubeでRotete.csで回転をかけただけのシーンをビルドしてみて、シーンは起動しましたが、回転はしませんでした、Rotete.csが読み込めてないためだと思います。
あなたの回答
tips
プレビュー