void Awake() { if (instance == null) { instance = this; } float sr = (float)Screen.width / (float)Screen.height; float tr = rampa.GetComponent <SpriteRenderer>().bounds.size.x / rampa.GetComponent <SpriteRenderer>().bounds.size.y; if (sr >= tr) { Camera.main.orthographicSize = rampa.GetComponent <SpriteRenderer>().bounds.size.y / 2; } else { float ds = tr / sr; Camera.main.orthographicSize = rampa.GetComponent <SpriteRenderer>().bounds.size.y / 2 * ds; } height = 2f * Camera.main.orthographicSize; width = height * Camera.main.aspect; rampa.transform.position = new Vector2(width / 2 - rampa.GetComponent <SpriteRenderer>().bounds.size.x / 2, -height / 2 + 0.5f); spike1.transform.position = new Vector2(width / 2 - spike1.GetComponent <SpriteRenderer>().bounds.size.x / 2, height / 2); spike2.transform.position = new Vector2(width / 2 - spike2.GetComponent <SpriteRenderer>().bounds.size.x / 2, -height / 2 + spike2.GetComponent <SpriteRenderer>().bounds.size.y / 2); //testObject.transform.position = new Vector2(0,height/2 - spike2.GetComponent<SpriteRenderer>().bounds.size.y/2-testObject.GetComponent<SpriteRenderer>().bounds.size.y/2-1.4f); }
public static void LoadGameOptionsDefaultInfo(string fileName, UniGameResources gameResources) { XmlDocument doc = gameResources.LoadResource_PublicXmlFile(fileName); XmlNode root = doc.SelectSingleNode("GameOptions"); XmlNode node = root.SelectSingleNode("GameDifficulty"); switch (node.Attribute("difficulty")) { case "Simpleness": defaultGameDifficulty = GameDifficulty.Difficulty_Simpleness; break; case "Normal": defaultGameDifficulty = GameDifficulty.Difficulty_Normal; break; case "Difficulty": defaultGameDifficulty = GameDifficulty.Difficulty_Difficulty; break; default: defaultGameDifficulty = GameDifficulty.Difficulty_Normal; break; } node = root.SelectSingleNode("Language"); if (!gameResources.FindLanguageDefine(UniGameResources.LanguageDefine.LanguageNameToLanguageId(node.Attribute("name")), out defaultGameLanguage)) { defaultGameLanguage = gameResources.GetDefineLanguage(); } node = root.SelectSingleNode("GameVolume"); defaultGameVolume = Convert.ToSingle(node.Attribute("volume")); defaultStandByMusicVolume = Convert.ToSingle(node.Attribute("standbymusicvolume")); node = root.SelectSingleNode("GameResolution"); if (node.Attribute("resolution") == GameResolution.Resolution_Default.ToString()) { defaultGameResolution = GameResolution.Resolution_Default; } else if (node.Attribute("resolution") == GameResolution.Resolution_16_9_1920_1080.ToString()) { defaultGameResolution = GameResolution.Resolution_16_9_1920_1080; } else if (node.Attribute("resolution") == GameResolution.Resolution_16_9_1600_900.ToString()) { defaultGameResolution = GameResolution.Resolution_16_9_1600_900; } else if (node.Attribute("resolution") == GameResolution.Resolution_16_9_1280_720.ToString()) { defaultGameResolution = GameResolution.Resolution_16_9_1280_720; } else { defaultGameResolution = GameResolution.Resolution_Default; } }
public static void OnLevelWillChange() { if (instance != null) { Destroy(instance); instance = null; } }
private void Start() { //float kof = SceneManager.GetActiveScene().name.Equals("LoginScene") ? 1 : 2; showSize = new Vector2(GameResolution.GetCurrentResolution().x * 0.7f, rectTransform.sizeDelta.y); hideSize = Vector2.zero; rectTransform.sizeDelta = hideSize; GetAllTextChildElements(rectTransform); }
public GameContextConfig(MonitorMode pResolution, int iDepth = 24, int iStencil = 8, bool bSamples = true, NativContextConfigTyp pGraphicType = NativContextConfigTyp.Best, VSyncMode pVsync = VSyncMode.Adaptive) { m_iDepth = iDepth; m_iStencil = iStencil; m_pResolution = new GameResolution(pResolution); m_pVSync = pVsync; m_pConfigTyp = pGraphicType; m_pConfigInt = 0; m_bSamples = bSamples; }
private void Awake() { if (instance == null) { instance = this; } else { DestroyImmediate(this); return; } _defaultDevelopmentCanvasScale = canvasRect.localScale.x; }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }