如何在param中成为类的属性



我被问自己。如何在功能参数中制作类的属性?我写了一个伪代码示例来解释我的想法。

private void UpdateCurrentGraphicSettingValue(Dropdown pDropdown, ??? pThing)
{
    if(pDropdown.value == 0)
    {
        CurrentGraphicsSetting.pThing = LowGraphicsSetting.pThing
    }
}

如果您有任何建议,它将非常有帮助。

我可以建议这样的东西吗?

如果有任何您不理解的部分,我会解释的。

public class test : MonoBehaviour {
    public GraphicSettings CurrentGraphicsSetting;
    public GraphicSettings LowGraphicsSetting = new GraphicSettings() { pThing1 = 23, pThing2 = "test23" };
    public GraphicSettings HighGraphicsSetting = new GraphicSettings() { pThing1 = 2300, pThing2 = "test23sd" };
    public class GraphicSettings
    {
        public int pThing1 = 0;
        public string pThing2 = "test";
    }
    private void UpdateCurrentGraphicSettingValue(Dropdown pDropdown)
    {
        if (pDropdown.value == 0)
        {
            CurrentGraphicsSetting = LowGraphicsSetting;
        }
        else
        {
            CurrentGraphicsSetting = HighGraphicsSetting;
        }
        ApplyGraphicSettings();
    }
    private void ApplyGraphicSettings()
    {
        SomeSetting = CurrentGraphicsSetting.pThing1;
        SomeOtherSetting = CurrentGraphicsSetting.pThing2;
    }
}

在您的帮助下,我终于解决了我的问题……就像这样:

private void UpdateCurrentGraphicSettingValue(Dropdown pDropdown, ref int p1, ref int p2)
{
    if(pDropdown.value == 0)
    {
        p1 = p2;
    }
UpdateCurrentGraphicSettingValue(myDropdown, ref CurrentGraphic.pixelLightCount, ref LowGraphic.pixelLightCount)

最新更新