void Awake() { SceneManager.sceneLoaded += CheckLevelLoaded; if (SaveData.currentSave == null) { Debug.Log("save file created"); SaveData.currentSave = new SaveData(-1); } if (global == null) { global = this; debugText = this.transform.Find("DEBUG").GetComponent <UI.Text>(); debugTextShadow = debugText.transform.Find("DEBUGShadow").GetComponent <UI.Text>(); Object.DontDestroyOnLoad(this.gameObject); if (!PlayerPrefs.HasKey("textSpeed") || !PlayerPrefs.HasKey("musicVolume") || !PlayerPrefs.HasKey("sfxVolume") || !PlayerPrefs.HasKey("frameStyle") || !PlayerPrefs.HasKey("battleScene") || !PlayerPrefs.HasKey("battleStyle") || !PlayerPrefs.HasKey("screenSize") || !PlayerPrefs.HasKey("fullscreen")) { //if a playerpref isn't set PlayerPrefs.SetInt("textSpeed", 2); float mVol = (7f / 20f) * (7f / 20f); float sVol = (14f / 20f) * (14f / 20f); PlayerPrefs.SetFloat("musicVolume", mVol); PlayerPrefs.SetFloat("sfxVolume", sVol); PlayerPrefs.SetInt("frameStyle", 1); PlayerPrefs.SetInt("battleScene", 1); PlayerPrefs.SetInt("battleStyle", 0); PlayerPrefs.SetInt("screenSize", 1); PlayerPrefs.SetInt("fullscreen", 0); PlayerPrefs.Save(); } updateResolution(); RenderTexture.active = GUIDisplay; GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f)); SetDEBUGFileData(); } else if (global != this) { Destroy(gameObject); } }
void Awake() { SaveLoad.Load(); fileDataPanel = transform.Find("FileData").gameObject; continueButton = transform.Find("Continue").gameObject; Transform newGameButton = transform.Find("NewGame"); Transform settingsButton = transform.Find("Settings"); Transform[] buttonTransforms = new Transform[] { continueButton.transform, newGameButton, settingsButton }; for (int i = 0; i < 3; i++) { button[i] = buttonTransforms[i].Find("ButtonTexture").GetComponent <GUITexture>(); buttonHighlight[i] = buttonTransforms[i].Find("ButtonHighlight").GetComponent <GUITexture>(); buttonText[i] = buttonTransforms[i].Find("Text").GetComponent <GUIText>(); buttonTextShadow[i] = buttonText[i].transform.Find("TextShadow").GetComponent <GUIText>(); } fileNumbersText = continueButton.transform.Find("FileNumbers").GetComponent <GUIText>(); fileNumbersTextShadow = fileNumbersText.transform.Find("FileNumbersShadow").GetComponent <GUIText>(); fileSelected = fileNumbersText.transform.Find("FileSelected").GetComponent <GUIText>(); mapNameText = fileDataPanel.transform.Find("MapName").GetComponent <GUIText>(); mapNameTextShadow = mapNameText.transform.Find("MapNameShadow").GetComponent <GUIText>(); dataText = fileDataPanel.transform.Find("DataText").GetComponent <GUIText>(); dataTextShadow = dataText.transform.Find("DataTextShadow").GetComponent <GUIText>(); for (int i = 0; i < 6; i++) { pokemon[i] = fileDataPanel.transform.Find("Pokemon" + i).GetComponent <GUITexture>(); } }
public static GameObject CreateTextElement(string elementName, string text, int size = 14, TextAnchor alignment = TextAnchor.MiddleLeft, GameObject parent = null) { GameObject goText = new GameObject(elementName); goText.transform.SetParent(parent.transform, false); goText.transform.transform.localPosition = Vector3.zero; goText.transform.transform.localScale = Vector3.one; UI.Text textComponent = goText.AddComponent <UI.Text>(); textComponent.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; textComponent.text = text; textComponent.alignment = alignment; textComponent.fontSize = size; textComponent.verticalOverflow = VerticalWrapMode.Overflow; textComponent.color = DebugMenuUI.kColorUnSelected; RectTransform rectTransform = goText.GetComponent <RectTransform>(); rectTransform.pivot = new Vector2(0.0f, 0.0f); rectTransform.localPosition = new Vector3(0.0f, 0.0f); rectTransform.anchorMin = new Vector2(0.0f, 0.0f); rectTransform.anchorMax = new Vector2(1.0f, 1.0f); return(goText); }
public Text() { AddComponent <CanvasRenderer>(); this.textComponent = AddComponent <UI.Text>(); this.font = Font.CreateDynamicFontFromOSFont("fonts/JetBrainsMono-Regular.ttf", 22); }