Is that a bug or is it a feature, Instead of copying the values, it "links them"?

Instead of copying the values, it “links them”
SavedSettings = CurrentSettings

Godot v4.2.1.stable.mono - Windows 10

SettingsScreenController.cs

using Godot;
using System;

public partial class SettingsScreenController : Node
{

	public static SettingsScreenController Instance;

	[ExportGroup("Screens Instances")]
	[Export] public Control SettingsScreenInstance;
	[Export] public Control PrevScreen;

	[ExportGroup("Buttons Instances")]

	[ExportSubgroup("Settings Buttons")]
    [Export] public Button AcceptBtnInstnace;
    [Export] public Button ResetBtnInstnace;
    [Export] public Button CancelInstnace;

	[ExportSubgroup("General Tab Settings")]
    [Export] public OptionButton LanguageBtnInstnace;
    [Export] public OptionButton DubsLanguageBtnInstnace;

    public SettingsFile CurrentSettings;

	public SettingsFile SavedSettings;

    // Called when the node enters the scene tree for the first time.s
    public override void _Ready()
	{
		Instance = this;
		CurrentSettings = new SettingsFile();
        SetDefaults();
        SavedSettings = CurrentSettings;

        AcceptBtnInstnace.ButtonDown += OnAcceptSettingsBtnDown;
		ResetBtnInstnace.ButtonDown += OnResetSettingsBtnDown;
		CancelInstnace.ButtonDown += OnCancelSettingsBtnDown;
		LanguageBtnInstnace.ItemSelected += OnLanguageSelectionChange;
		DubsLanguageBtnInstnace.ItemSelected += OnDubsLanguageSelectionChange;

    }

    public void OnLanguageSelectionChange(long id)
	{
		CurrentSettings.SelectedLanguage = id;
	}

    public void OnDubsLanguageSelectionChange(long id)
    {
        CurrentSettings.SelectedDubsLanguage = id;
    }

    public void OnAcceptSettingsBtnDown()
	{
        string _localName = SettingsFile.GetLocalNameFromID(CurrentSettings.SelectedLanguage);
        TranslationServer.SetLocale(_localName);

		SavedSettings = CurrentSettings;

        HideSettings();

	}

	public void OnResetSettingsBtnDown()
	{
		CurrentSettings = new SettingsFile();

		OverrideThings();

    }

	public void OnCancelSettingsBtnDown()
	{

		HideSettings();

	}

	private void HideSettings()
	{
		ChangeState(false);
		PrevScreen.Visible = true;
	}

	private void SetDefaults()
	{
        CurrentSettings.SelectedLanguage = SettingsFile.GetLocalIDFromName(TranslationServer.GetLocale());
        CurrentSettings.SelectedDubsLanguage = 0;
    }

	private void OverrideThings()
	{
        GD.Print("L: " + SavedSettings.SelectedLanguage + "DL: " + SavedSettings.SelectedDubsLanguage);
        LanguageBtnInstnace.Select((int) SavedSettings.SelectedLanguage);
        DubsLanguageBtnInstnace.Select((int) SavedSettings.SelectedDubsLanguage);
    }

	public void ShowSettings()
	{
        ChangeState(true);

		OverrideThings();

	}

	public void ChangeState(bool state)
	{
		SettingsScreenInstance.Visible = state;
	}
}

SettingsFile.cs

using Godot;
using System;

[Serializable]
public class SettingsFile
{
    public float SelectedLanguage = 0;
    public float SelectedDubsLanguage = 0;

    public static string GetLocalNameFromID(float localID)
    {
        switch (localID)
        {
            case 1: return "pl";
            default: return "en";
        }
    }

    public static int GetLocalIDFromName(string localName)
    {
        switch (localName)
        {
            case "pl": return 1;
            case "pl_PL": return 1;
            default: return 0;
        }
    }
}

the SettingsFile.cs doesnt extends from anything?

needs to be extended from something?

if it’s a refcounted, i think it can be initialized, and the value should not be the same

i suppose if it’s not specified, it’s basically just an Object. i usually at very least use refcounted

still after i made

using Godot;
using System;

public partial class SettingsFile : Resource
{
    public float SelectedLanguage = 0;
    public float SelectedDubsLanguage = 0;

    public static string GetLocalNameFromID(float localID)
    {
        switch (localID)
        {
            case 1: return "pl";
            default: return "en";
        }
    }

    public static int GetLocalIDFromName(string localName)
    {
        switch (localName)
        {
            case "pl": return 1;
            case "pl_PL": return 1;
            default: return 0;
        }
    }
}

since here you used extends from Resource
then you can Duplicate(true) the CurrentSettings before assigning it to SavedSettings

still “links them”

using Godot;
using System;

public partial class SettingsScreenController : Node
{

	public static SettingsScreenController Instance;

	[ExportGroup("Screens Instances")]
	[Export] public Control SettingsScreenInstance;
	[Export] public Control PrevScreen;

	[ExportGroup("Buttons Instances")]

	[ExportSubgroup("Settings Buttons")]
    [Export] public Button AcceptBtnInstnace;
    [Export] public Button ResetBtnInstnace;
    [Export] public Button CancelInstnace;

	[ExportSubgroup("General Tab Settings")]
    [Export] public OptionButton LanguageBtnInstnace;
    [Export] public OptionButton DubsLanguageBtnInstnace;

    public SettingsFile CurrentSettings;

	public SettingsFile SavedSettings;

    // Called when the node enters the scene tree for the first time.s
    public override void _Ready()
	{
		Instance = this;
		CurrentSettings = new SettingsFile();
        SetDefaults();
        CurrentSettings.Duplicate(true);
        SavedSettings = CurrentSettings;

        AcceptBtnInstnace.ButtonDown += OnAcceptSettingsBtnDown;
		ResetBtnInstnace.ButtonDown += OnResetSettingsBtnDown;
		CancelInstnace.ButtonDown += OnCancelSettingsBtnDown;
		LanguageBtnInstnace.ItemSelected += OnLanguageSelectionChange;
		DubsLanguageBtnInstnace.ItemSelected += OnDubsLanguageSelectionChange;

    }

    public void OnLanguageSelectionChange(long id)
	{
		CurrentSettings.SelectedLanguage = id;
	}

    public void OnDubsLanguageSelectionChange(long id)
    {
        CurrentSettings.SelectedDubsLanguage = id;
    }

    public void OnAcceptSettingsBtnDown()
	{
        string _localName = SettingsFile.GetLocalNameFromID(CurrentSettings.SelectedLanguage);
        TranslationServer.SetLocale(_localName);

                CurrentSettings.Duplicate(true)
		SavedSettings = CurrentSettings;

        HideSettings();

	}

	public void OnResetSettingsBtnDown()
	{
		CurrentSettings = new SettingsFile();

		OverrideThings();

    }

	public void OnCancelSettingsBtnDown()
	{

		HideSettings();

	}

	private void HideSettings()
	{
		ChangeState(false);
		PrevScreen.Visible = true;
	}

	private void SetDefaults()
	{
        CurrentSettings.SelectedLanguage = SettingsFile.GetLocalIDFromName(TranslationServer.GetLocale());
        CurrentSettings.SelectedDubsLanguage = 0;
    }

	private void OverrideThings()
	{
        GD.Print("L: " + SavedSettings.SelectedLanguage + "DL: " + SavedSettings.SelectedDubsLanguage);
        LanguageBtnInstnace.Select((int) SavedSettings.SelectedLanguage);
        DubsLanguageBtnInstnace.Select((int) SavedSettings.SelectedDubsLanguage);
    }

	public void ShowSettings()
	{
        ChangeState(true);

		OverrideThings();

	}

	public void ChangeState(bool state)
	{
		SettingsScreenInstance.Visible = state;
	}
}

where the duplicate?

I edited it bc i send not what i wanted

you obviously put it to saved settings right away, because duplicate returns something, but assigned to nothing
change to this
SavedSettings = CurrentSettings.Duplicate(true);

I getting this:

is this fix?

SavedSettings = CurrentSettings.Duplicate(true) as SavedSettings;

I’m no expert on C#, but perhaps Duplicate() on C# returns a generic resource type and you need to cast it?

yeah looks like it, it seems he done it

now getting:
in Debugger

E 0:00:19:0292   void SettingsScreenController.OverrideThings(): System.NullReferenceException: Object reference not set to an instance of an object.
  <Błąd C#>      System.NullReferenceException
  <Źródło C#>    SettingsScreenController.cs:99 @ void SettingsScreenController.OverrideThings()
  <Ślad stosu>   SettingsScreenController.cs:99 @ void SettingsScreenController.OverrideThings()
                 SettingsScreenController.cs:72 @ void SettingsScreenController.OnResetSettingsBtnDown()
                 Callable.generics.cs:39 @ void Godot.Callable.<From>g__Trampoline|1_0(object, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant&)
                 DelegateUtils.cs:62 @ void Godot.DelegateUtils.InvokeWithVariantArgs(nint, System.Void*, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant*)

and in console

Godot Engine v4.2.1.stable.mono.official.b09f793f5 - https://godotengine.org
 
  Cannot open file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed to read file: '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Cannot load C# script file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed loading resource: /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs. Make sure resources have been imported by opening the project in the editor at least once.
  Cannot open file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed to read file: '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Cannot load C# script file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed loading resource: /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs. Make sure resources have been imported by opening the project in the editor at least once.
  Cannot open file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed to read file: '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Cannot load C# script file '/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs'.
  Failed loading resource: /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs. Make sure resources have been imported by opening the project in the editor at least once.

this is the error now, what’s in line 99?

yes, is this line

private void OverrideThings()
{
  //GD.Print("Saved: SelectedLanguage: " + SavedSettings.SelectedLanguage + "SelectedDubbingLanguage: " + SavedSettings.SelectedDubsLanguage + " | Current: SelectedLanguage: " + CurrentSettings.SelectedLanguage + "SelectedDubbingLanguage: " + CurrentSettings.SelectedDubsLanguage);
  LanguageBtnInstnace.Select((int) SavedSettings.SelectedLanguage);
  DubsLanguageBtnInstnace.Select((int) SavedSettings.SelectedDubsLanguage);
}

check if you already assigned the button in the inspector dock

i found why ScriptManagerBridge.cs causing error:
it haves problem with converting Godot.Resource to SettingsFile

image

I found solution here: