2

我正在尝试使用 ios 设备上的设置面板来显示我的设置。我已阅读有关该主题的这些资料;

http://forum.unity3d.com/threads/23699-App-Settings http://answers.unity3d.com/questions/40506/ios-application-in-the-settings-panel.html

这不是正在开发的游戏,应用内设置不合适。如果您想对这个选择提出质疑,那么只需为应用程序付费的人将其列为固定的明确要求,并且不愿意更改此要求。

我目前遇到的问题是,尽管有一个完整的 Settings.bundle,但我无法在 iOS 设备上正确接收我的设置。

源代码可以在下面找到。令人困惑的部分是“manual_session_control”和“ignore_screen_locks”在使用时正在注册;

PlayerPrefs.HasKey(...);

但是当调用 .GetInt 的 .GetString() 时,会返回空字符串或 0。没有 PlayerPrefs.GetBool()。

此外,调用 PlayerPrefs.HasKey(...); 时其他值返回 false;任何人都可以对这个问题做出一些澄清。我在 Unity 4.2.1 上。

设置列表

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
    <dict>
        <key>Title</key>
        <string>Configurator</string>
        <key>Type</key>
        <string>PSGroupSpecifier</string>
    </dict>
    <dict>
        <key>AutocapitalizationType</key>
        <string>None</string>
        <key>AutocorrectionType</key>
        <string>No</string>
        <key>DefaultValue</key>
        <string>127.0.0.1</string>
        <key>IsSecure</key>
        <false/>
        <key>Key</key>
        <string>server_ip</string>
        <key>KeyboardType</key>
        <string>URL</string>
        <key>Title</key>
        <string>Host Address</string>
        <key>Type</key>
        <string>PSTextFieldSpecifier</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSTextFieldSpecifier</string>
        <key>Title</key>
        <string>Host Port</string>
        <key>DefaultValue</key>
        <string>4782</string>
        <key>Key</key>
        <string>server_port</string>
        <key>AutocorrectionType</key>
        <string>No</string>
        <key>KeyboardType</key>
        <string>NumberPad</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSToggleSwitchSpecifier</string>
        <key>Title</key>
        <string>Manual Session Control</string>
        <key>Key</key>
        <string>manual_session_control</string>
        <key>DefaultValue</key>
        <false/>
        <key>TrueValue</key>
        <string>true</string>
        <key>FalseValue</key>
        <string>false</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSTextFieldSpecifier</string>
        <key>Title</key>
        <string>Theme</string>
        <key>Key</key>
        <string>theme</string>
        <key>DefaultValue</key>
        <string>Basic</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSGroupSpecifier</string>
        <key>Title</key>
        <string>Debug</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSToggleSwitchSpecifier</string>
        <key>Title</key>
        <string>Ignore Screen Locks</string>
        <key>Key</key>
        <string>ignore_screen_locks</string>
        <key>DefaultValue</key>
        <string></string>
        <key>TrueValue</key>
        <string>true</string>
        <key>FalseValue</key>
        <string>false</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSToggleSwitchSpecifier</string>
        <key>Title</key>
        <string>Show Screen Log</string>
        <key>Key</key>
        <string>show_screen_log</string>
        <key>DefaultValue</key>
        <false/>
        <key>TrueValue</key>
        <string>true</string>
        <key>FalseValue</key>
        <string>false</string>
    </dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>

统一代码

#elif UNITY_IPHONE
IP = PlayerPrefs.GetString("server_ip");
Port = PlayerPrefs.GetInt("server_port");
ManualSessionControl = PlayerPrefs.GetString("manual_session_control") == "true" ? true : false;
IgnoreScreenLock = PlayerPrefs.GetString("ignore_screen_locks") == "true" ? true : false;
Theme = PlayerPrefs.GetString("theme");
4

0 回答 0