我被问到了自己。如何在函数参数中创建类的属性? 我写了一个伪代码示例来解释我的想法。
private void UpdateCurrentGraphicSettingValue(Dropdown pDropdown, ??? pThing)
{
if(pDropdown.value == 0)
{
CurrentGraphicsSetting.pThing = LowGraphicsSetting.pThing
}
}
如果您有任何建议,将会非常有帮助。
答案 0 :(得分:3)
我可以建议这样的事吗?
如果有任何你不理解的部分,我会解释。
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;
}
}
答案 1 :(得分:0)
在你的帮助下我终于解决了我的问题......就像这样:
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)