版本: Unity 6 (6000.0)
语言英语
  • C#

PlayerSettings.defaultScreenHeight

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交的内容,但我们会阅读用户提出的每个建议的更改,并在适用的情况下进行更新。

关闭

提交失败

由于某种原因,您的建议更改无法提交。请<a>重试</a>几分钟后。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

切换到手册
public static int defaultScreenHeight;

描述

独立播放器窗口的默认垂直尺寸。


自定义播放器设置。

using UnityEngine;
using UnityEditor;

// Simple Script that saves and loads custom // Stand-alone/Web player screen settings among // Unity Projects

class CustomSettings : EditorWindow {

string compName = ""; string prodName = ""; int screenWidth = 640; int screenHeight = 480; int webScreenWidth = 640; int webScreenHeight = 480; bool fullScreen = false;

[MenuItem("Examples/Custom Settings")] static void Init() { var window = GetWindow<CustomSettings>(); window.Show(); }

void OnGUI() { compName = EditorGUILayout.TextField("Company Name:", compName); prodName = EditorGUILayout.TextField("Product Name:", prodName); EditorGUILayout.BeginHorizontal(); screenWidth = EditorGUILayout.IntField("Width:", screenWidth); screenHeight = EditorGUILayout.IntField("Web Height:", screenHeight); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); webScreenWidth = EditorGUILayout.IntField("Web Width:", webScreenWidth); webScreenHeight = EditorGUILayout.IntField("Web Height:", webScreenHeight); EditorGUILayout.EndHorizontal(); fullScreen = EditorGUILayout.Toggle("Full Screen:", fullScreen); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save Values")) SaveSettings(); if (GUILayout.Button("Load Values")) LoadSettings(); EditorGUILayout.EndHorizontal(); }

void SaveSettings() { PlayerSettings.companyName = compName; PlayerSettings.productName = prodName; PlayerSettings.defaultScreenWidth = screenWidth; PlayerSettings.defaultScreenHeight = screenHeight; PlayerSettings.defaultWebScreenWidth = webScreenWidth; PlayerSettings.defaultWebScreenHeight = webScreenHeight; PlayerSettings.defaultIsFullScreen = fullScreen;

EditorPrefs.SetString("CompName", compName); EditorPrefs.SetString("ProdName", prodName); EditorPrefs.SetInt("ScreenWidth", screenWidth); EditorPrefs.SetInt("ScreenHeight", screenHeight); EditorPrefs.SetInt("WebScreenWidth", webScreenWidth); EditorPrefs.SetInt("WebScreenHeight", webScreenHeight); } void LoadSettings() { compName = EditorPrefs.GetString("CompName", ""); prodName = EditorPrefs.GetString("ProdName", ""); screenWidth = EditorPrefs.GetInt("ScreenWidth", 640); screenHeight = EditorPrefs.GetInt("ScreenHeight", 480); webScreenWidth = EditorPrefs.GetInt("WebScreenWidth", 640); webScreenHeight = EditorPrefs.GetInt("WebScreenHeight", 480); } }