fungus

Open full view…

Issue with a custom script

blabla38
Thu, 07 Jun 2018 08:44:17 GMT

So I made this script to change my background, importing images from a file : using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Fungus; [CommandInfo("Sprite", "Change Sprite", "Change the sprite of the background")] public class ChangeSpriteFungus : Command { public GameObject Background; Sprite Image; public string path; public override void OnEnter() { Image = ChangeSprite.LoadNewSprite(Application.dataPath + "/Images/" + path); Background.GetComponent<Image>().sprite = Image; Continue(); } public override string GetSummary() { string summary = ""; if (path != null) summary = path; return path; } public override Color GetButtonColor() { return new Color32(221, 184, 169, 255); } } It worked perfectly. But when I've restarted Unity. If I had a new one in a block, when I launch the game, the command is deleted and I have this error : "GameObject (named 'Flowchart') references runtime script in scene file. Fixing!" and "The referenced script on this Behaviour (Game Object 'Flowchart') is missing!" The weird thing is that the same command set before restarting Unity still work. Only the new ones doesn't work. Any ideas? Thanks

wolfrug
Thu, 07 Jun 2018 09:18:23 GMT

Yah, this is a weird but normal Unity error. The problem is that the name of the method (ChangeSpriteFungus) has to be exactly the same as the *.cs filename that contains the command. So it too has to be ChangeSpriteFungus.cs. It'll work, but then throw weird errors when you restart/randomly/whenever.

blabla38
Thu, 07 Jun 2018 11:29:19 GMT

Thanks a lot. For now it seems to work.