Merge pull request #3 from Unity-Technologies/ScreenSelectorExample
Screen selector example
This commit is contained in:
Коммит
4f8c4909f5
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClosingScript : MonoBehaviour
|
||||
public class ClosingScript
|
||||
{
|
||||
private void OnApplicationQuit()
|
||||
private static void Quit()
|
||||
{
|
||||
List<string> settings = new List<string>
|
||||
{
|
||||
|
@ -17,15 +17,18 @@ public class ClosingScript : MonoBehaviour
|
|||
"UnitySelectMonitor"
|
||||
};
|
||||
|
||||
using (StreamWriter file = new StreamWriter("ScreenSelectorPrefs.txt"))
|
||||
using (StreamWriter file = new StreamWriter(Path.Combine(Application.persistentDataPath, "ScreenSelectorPrefs.txt")))
|
||||
{
|
||||
foreach(string key in settings)
|
||||
foreach (string key in settings)
|
||||
{
|
||||
file.WriteLine(PlayerPrefs.GetInt(key, 0).ToString());
|
||||
}
|
||||
|
||||
file.Flush();
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void RunOnStart()
|
||||
{
|
||||
Application.quitting += Quit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@ public class PostProcessLauncherCopy
|
|||
[PostProcessBuildAttribute(1)]
|
||||
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
string dataPath = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), "PersistentDataPath.txt");
|
||||
using (StreamWriter file = new StreamWriter(dataPath))
|
||||
{
|
||||
file.WriteLine(Path.Combine(Application.companyName, Application.productName));
|
||||
}
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
|
|
|
@ -121,49 +121,6 @@ NavMeshSettings:
|
|||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &514779246
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 514779247}
|
||||
- component: {fileID: 514779248}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &514779247
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 514779246}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &514779248
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 514779246}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 93a8018bd49bbf1458edf2998ccb8717, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -10,6 +10,7 @@
|
|||
#include <fstream>
|
||||
#include <math.h>
|
||||
#include <set>
|
||||
#include <ShlObj.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -446,10 +447,56 @@ std::wstring ConstructCommandLine()
|
|||
return command;
|
||||
}
|
||||
|
||||
std::wstring GetDataPath()
|
||||
{
|
||||
std::wstring path;
|
||||
std::wstring dir;
|
||||
|
||||
// When run from VS or other debugging places, current working directory can be set to something else.
|
||||
dir.resize(MAX_PATH);
|
||||
GetModuleFileName(NULL, LPWSTR(dir.data()), MAX_PATH);
|
||||
|
||||
size_t pathCharLocation = dir.find_last_of(L"\\");
|
||||
if (pathCharLocation == std::string::npos)
|
||||
return path;
|
||||
|
||||
dir.replace(pathCharLocation + 1, dir.length(), L"PersistentDataPath.txt");
|
||||
|
||||
|
||||
// Get AppData path
|
||||
PWSTR appDataLocalLow = NULL;
|
||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, NULL, &appDataLocalLow);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
path.append(appDataLocalLow);
|
||||
CoTaskMemFree(appDataLocalLow);
|
||||
appDataLocalLow = NULL;
|
||||
|
||||
|
||||
// Get data path
|
||||
std::wifstream pathFile(dir);
|
||||
|
||||
if (!pathFile.is_open())
|
||||
return std::wstring();
|
||||
|
||||
std::wstring pathInfo;
|
||||
std::getline(pathFile, pathInfo);
|
||||
pathFile.close();
|
||||
|
||||
path.append(L"\\" + pathInfo + L"\\ScreenSelectorPrefs.txt");
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
void ReadPreferences()
|
||||
{
|
||||
// Open, read, and close file
|
||||
std::ifstream file("ScreenSelectorPrefs.txt");
|
||||
std::ifstream file(GetDataPath());
|
||||
const int numPrefs = 6;
|
||||
int values[numPrefs] = { 0 };
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче