Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Dropdown doesn't save first value by default #213

Closed
kirpit opened this issue Feb 19, 2021 · 1 comment
Closed

[Issue] Dropdown doesn't save first value by default #213

kirpit opened this issue Feb 19, 2021 · 1 comment

Comments

@kirpit
Copy link

kirpit commented Feb 19, 2021

using UnityEngine;
using NaughtyAttributes;

[CreateAssetMenu(fileName="New Naugty Item", menuName="Naugty Item", order=61)]
public class NaughtyScriptable : ScriptableObject
{
    [Dropdown("_intValues")]
    public int intDropdown;
    private int[] _intValues = new int[] {10, 20};
    
    [Dropdown("_stringValues")]
    public string stringDropdown;
    private string[] _stringValues = new string[] {"SILVER", "GOLD"};
}

Steps to repeat:

  • Drop the above code in your project.
  • Create a new scriptable asset by "Assets => Create => Naugty Item" (perhaps in your Resources folder).
  • Do not change any value and leave as is.
  • Load the created asset and display its values; intDropdown / stringDropdown

Expected result

intDropdown == 10 and stringDropdown == "SILVER" as it displays on the inspection menu when first created.

Actual result

intDropdown == 0 and stringDropdown == "" which are the default values of an int and string.

To have them set the first given values, you need to click to the dropdown in inspection and explicitly choose the first value that is visually no different then leaving it as it was. This is overall misleading and took me quite a few hours to understand where the problem is.

Thanks for the great library though, much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants