Forum rules - please read before posting.

Errors when upgrading from 1.70.4 -> 1.71.2

edited May 20 in Technical Q&A

I've updated my project to the latest AC, but get these two compiler errors preventing me from running the game:

Assets\Scripts\PopulateWithScenes.cs(37,36): error CS7036: There is no argument given that corresponds to the required formal parameter '_filename' of 'SceneInfo.SceneInfo(int, string)'

Assets\Scripts\PopulateWithScenes.cs(38,43): error CS1503: Argument 1: cannot convert from 'AC.SceneInfo' to 'int'

Any idea what I should look for?

EDIT: Huh, I see that the AC top menu has disappeared from my project after I did an import. I think the project could have been corrupted somehow, got a "The associated script cannot be loaded" on every script in the project... Ouch! I did an import from the Asset store just like the other times I've upgraded. Good to have version control :)

EDIT 2: It seems it's the same issue as this post:
https://adventurecreator.org/forum/discussion/8425/anyone-else-have-trouble-loading-ac-with-newest-unity

Comments

  • If you reload Unity while a script compilation error exists, it will prevent custom toolbars, such as ACs, from loading.

    See the update's Changelog - the SceneInfo class is now used internally only, with scene functions now accepting the build index number as a parameter.

    To convert a scene name to its build index number, use:

    int sceneIndex = KickStater.sceneChanger.NameToIndex (_filename);
    

    If you need help with updating your script, I would have to see the code.

  • Ah, in my brain dead state I figured PopulateWithScenes was an AC script, not something I'd concocted myself :blush:

    That's a script I added to a debug menu to quickly jump to any scene in the project for debug/playtesting purposes:

     public class PopulateWithScenes : MonoBehaviour
    {
        Dropdown m_Dropdown;
        private GameObject menu;
        // Start is called before the first frame update
        void Start()
        {
    
            var optionDataList = new List<Dropdown.OptionData>();
    
            for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; ++i)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
                optionDataList.Add(new Dropdown.OptionData(name));
            }
    
            GetComponent<Dropdown>().ClearOptions();
            GetComponent<Dropdown>().AddOptions(optionDataList);
    
            //Fetch the Dropdown GameObject
            m_Dropdown = GetComponent<Dropdown>();
            //Add listener for when the value of the Dropdown changes, to take action
            m_Dropdown.onValueChanged.AddListener(delegate {
                DropdownValueChanged(m_Dropdown);
            });
    
        }
    
        //Ouput the new value of the Dropdown into Text
        void DropdownValueChanged(Dropdown change)
        {
            AC.SceneInfo nextSceneInfo = new AC.SceneInfo(change.value);
            AC.KickStarter.sceneChanger.ChangeScene(nextSceneInfo, true);
            AC.PlayerMenus.GetMenuWithName("NewGame").TurnOff();
    
        }
    }
    
  • Replace that last function with this:

    void DropdownValueChanged (Dropdown change)
    {
        int nextSceneIndex = AC.KickStarter.sceneChanger.NameToIndex (change.value);
        AC.KickStarter.sceneChanger.ChangeScene (nextSceneIndex, true);
        AC.PlayerMenus.GetMenuWithName ("NewGame").TurnOff();
    }
    
  • Thank you! Just a minor error, I had to change the change.value to change.name to get it to work. Here is the complete script if anyone wants to add a dropdown menu with all the scenes of your game to quickly go from one scene to another. (Note, you might have to add some more logic to remove the menu your dropdown component is inside, or some other housekeeping):

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using UnityEngine.SceneManagement;
    using AC;
    
    public class PopulateWithScenes : MonoBehaviour
    {
        Dropdown m_Dropdown;
        private GameObject menu;
        // Start is called before the first frame update
        void Start()
        {
    
            var optionDataList = new List<Dropdown.OptionData>();
    
            for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; ++i)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
                optionDataList.Add(new Dropdown.OptionData(name));
            }
    
            GetComponent<Dropdown>().ClearOptions();
            GetComponent<Dropdown>().AddOptions(optionDataList);
    
            //Fetch the Dropdown GameObject
            m_Dropdown = GetComponent<Dropdown>();
            //Add listener for when the value of the Dropdown changes, to take action
            m_Dropdown.onValueChanged.AddListener(delegate {
                DropdownValueChanged(m_Dropdown);
            });
    
        }
    
        //Ouput the new value of the Dropdown into Text
        void DropdownValueChanged (Dropdown change)
        {
            int nextSceneIndex = AC.KickStarter.sceneChanger.NameToIndex(change.name);
            AC.KickStarter.sceneChanger.ChangeScene (nextSceneIndex, true);
            //AC.PlayerMenus.GetMenuWithName ("NewGame").TurnOff();
        }
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!