// Start is called before the first frame update void Start() { var canvas = GameObject.Find("Canvas").transform; titleText = canvas.Find("How Text").GetComponent <Text>(); titleText.text = TextAssetLoader.GetCorrectTextAsset("Help/Help").text; instructionText = canvas.Find("Instruction Text").GetComponent <Text>(); homeButton = canvas.Find("Return Button").GetComponent <Button>(); backButton = canvas.Find("Back Button").GetComponent <Button>(); nextButton = canvas.Find("Next Button").GetComponent <Button>(); homeButton.onClick.AddListener(() => SceneManager.LoadScene("MainMenu")); backButton.onClick.AddListener(() => { instructionIndex--; audioSource.Play(); UpdateText(); }); nextButton.onClick.AddListener(() => { instructionIndex++; audioSource.Play(); UpdateText(); }); animator = FindObjectOfType <Animator>(); audioSource = GetComponent <AudioSource>(); UpdateText(); }
void UpdateText() { instructionText.text = TextAssetLoader.GetCorrectTextAsset($"{textPath}{instructionIndex}").text; backButton.gameObject.SetActive(true); nextButton.gameObject.SetActive(true); switch (instructionIndex) { case 0: backButton.gameObject.SetActive(false); animator.Play("Idle"); break; case 1: animator.Play("Walk"); break; case 2: animator.Play("Hit"); break; case 3: animator.Play("Panque"); break; case 4: animator.Play("Dance"); nextButton.gameObject.SetActive(false); break; } }
// Start is called before the first frame update void Start() { gameMenu = new GameMenu(GameObject.Find("Game Menu").transform); winText = TextAssetLoader.GetCorrectTextAsset("Game/Game").text; gameMenu.otherGameButton.onClick.AddListener(() => ButtonFunction(() => ChangeScene("Game"))); gameMenu.homeButton.onClick.AddListener(() => ButtonFunction(() => ChangeScene("MainMenu"))); gameMenu.pauseButton.onClick.AddListener(() => ButtonFunction(ShowPauseMenu)); gameMenu.resumeButton.onClick.AddListener(() => ButtonFunction(HidePauseMenu)); gameMenu.goHomeButton.onClick.AddListener(() => ButtonFunction(GoHome)); barricaModel = Resources.Load <GameObject>($"{prefabObjectPath}barrica"); panqueModel = Resources.Load <GameObject>($"{prefabObjectPath}panque"); spawnManager = GameObject.Find("Spawn Manager").transform; alienManager = GameObject.Find("Alien Manager").transform; borderManager = GameObject.Find("Border Manager").transform; musicManager = FindObjectOfType <MusicManager>(); musicManager.PlayNewClip(musicManager.gameMusic); audioSource = GetComponent <AudioSource>(); SetColors(); SetAliens(); SetPanqueLocation(); }
void LoadData() { TextAssetLoader.GetWords(ref BadWordsAsset, ref badWords); TextAssetLoader.GetWords(ref GoodWordsAsset, ref goodWords); // check load results Debug.Log("bad words # = " + badWords.Count); Debug.Log("good words # = " + goodWords.Count); }
// Helper functions void GenerateGUI() { Amount = new int[6]; numberText = new tk2dTextMesh[6]; Gadgets = GadgetIncludeInfo.Gadgets; Thumbnails = new tk2dSprite[6]; GadgetIncludeInfo[] gii = TextAssetLoader.GetIncludedGadgets(Application.loadedLevelName); // Add their total length for spacing float lengthSum = distanceBetweenGadgets * 5; for (int i = 0; i < 6; ++i) { lengthSum += GadgetIncludeInfo.Thumbnails[i].GetUntrimmedBounds().size.x; } // Set the dimensions (assumes current size is sufficient for one gadget) //sliceSprite.dimensions = new Vector2(sliceSprite.dimensions.x * 6, sliceSprite.dimensions.y); // Generate the thumbnails and add to tray float cumulativeLength = 0f; for (int i = 0; i < 6; ++i) { float positionX = -(lengthSum * 0.5f) + cumulativeLength + GadgetIncludeInfo.Thumbnails[i].GetUntrimmedBounds().size.x * 0.5f; GameObject thumbnail = Instantiate(GadgetIncludeInfo.Thumbnails[i].gameObject, new Vector3(positionX, 0f, -0.05f) + transform.position, transform.rotation) as GameObject; thumbnail.transform.parent = transform; Thumbnails[i] = thumbnail.GetComponent <tk2dSprite>(); Thumbnails[i].color = new Color(0.5f, 0.5f, 0.5f, 1f); cumulativeLength += Thumbnails[i].GetUntrimmedBounds().size.x + distanceBetweenGadgets; GameObject text = (Instantiate(TextSprite.gameObject, new Vector3(positionX + 0.44f, 0.5f, -0.1f) + transform.position, transform.rotation) as GameObject); text.transform.parent = transform; numberText[i] = text.GetComponent <tk2dTextMesh>(); numberText[i].color *= 0.5f; numberText[i].text = "0"; numberText[i].Commit(); } foreach (GadgetIncludeInfo info in gii) { for (int i = 0; i < 6; i++) { if (Gadgets[i].name.StartsWith(info.Gadget)) { Amount[i] = info.Amount; numberText[i].text = Amount[i].ToString(); numberText[i].color *= 2f; numberText[i].Commit(); Thumbnails[i].color = new Color(1f, 1f, 1f, 1f); } } } }
void LoadDate() { TextAssetLoader.GetWords(ref BadResponsesAsset, ref badResponses); TextAssetLoader.GetWords(ref GoodResponsesAsset, ref goodResponses); TextAssetLoader.GetWords(ref NeutralResponsesAsset, ref neutralResponses); // check load results Debug.Log("bad responses # = " + badResponses.Count); Debug.Log("good responses # = " + goodResponses.Count); Debug.Log("neutral responses # = " + neutralResponses.Count); }
void SetTexts() { textJson = JsonUtility.FromJson <ConfigText>(TextAssetLoader.GetCorrectTextAsset("Menu/Configuration").text); languageButton.GetComponentInChildren <Text>().text = textJson.languageButton; controlButton.GetComponentInChildren <Text>().text = textJson.controlsButton; spanishButton.GetComponentInChildren <Text>().text = textJson.spansih; englishButton.GetComponentInChildren <Text>().text = textJson.english; for (int i = 0; i < players.Count; i++) { players[i].text = $"{textJson.player} {i + 1}"; } }
// Unity defined functions void Start() { Debugdraw = CameraBounds; Rect rect = TextAssetLoader.GetCameraBounds(Application.loadedLevelName); Debugdraw = rect; CameraBounds = rect; // Figures out what the maximum zoom can be and sets it to that screenRatio = ((float)Screen.width / (float)Screen.height); float height = CameraBounds.height; float width = CameraBounds.width / screenRatio; if (height < width) { // Use height as max ortho MaxCameraOrthoSize = height * 0.5f; } else { // Use width as max ortho MaxCameraOrthoSize = (CameraBounds.width * 0.5f) / screenRatio; } if (MaxCameraOrthoSize < MinCameraOrthoSize) { Camera.main.orthographicSize = MinCameraOrthoSize = MaxCameraOrthoSize; } Camera.main.orthographicSize = MaxCameraOrthoSize; transform.localScale = (Vector3.up + Vector3.right) * Camera.main.orthographicSize * 0.2f + Vector3.forward; // Update the position of the background so it centers correctly CheckCameraBounds(); float dx = transform.position.x - (rect.xMin + rect.width * 0.5f); CameraMoved(new Vector3(dx, 0f)); float rightBound = transform.position.x + Camera.main.orthographicSize * screenRatio; if (rightBound > rect.xMax - 2f) { Destroy(OffscreenArrow); } else { iTween.MoveBy(OffscreenArrow, iTween.Hash( "x", 0.4f, "time", 0.8f, "looptype", iTween.LoopType.pingPong, "easetype", iTween.EaseType.linear)); } }
// Start is called before the first frame update void Start() { mainMenuText = JsonUtility.FromJson <MainMenuText>(TextAssetLoader.GetCorrectTextAsset(textDirection).text); var panel = GameObject.Find("Canvas").transform; firstMenu = new FirstMenu(panel.Find("First Menu")); playersMenu = new PlayersMenu(panel.Find("Players Menu")); credistMenu = new CredistMenu(panel.Find("Credits Menu")); colorMenu = new ColorMenu(panel.Find("Color Menu")); clickManager = GameObject.Find("Click Manager").GetComponent <AudioSource>(); playersMenu.howManyPlayerText.text = mainMenuText.numberOfPlayerText; for (int i = 0; i < playersMenu.playersButtons.Length; i++) { playersMenu.playersButtons[i].GetComponentInChildren <Text>().text = $"{i + 2}"; } firstMenu.playButton.onClick.AddListener(() => ButtonFunction(ShowPlayerMenu)); firstMenu.infoButton.onClick.AddListener(() => ButtonFunction(ShowCreditMenu)); for (int i = 0; i < playersMenu.playersButtons.Length; i++) { int x = i + 2; playersMenu.playersButtons[i].onClick.AddListener(() => ButtonFunction(() => ShowColorMenu(x))); } firstMenu.configButton.onClick.AddListener(() => ButtonFunction(() => SceneManager.LoadScene("Configuration"))); firstMenu.howButton.onClick.AddListener(() => ButtonFunction(() => SceneManager.LoadScene("Help"))); playersMenu.returnButton.onClick.AddListener(() => ButtonFunction(ShowFirstMenu)); credistMenu.returnButton.onClick.AddListener(() => ButtonFunction(ShowFirstMenu)); credistMenu.malenyButton.onClick.AddListener(() => Application.OpenURL("https://www.linkedin.com/in/elena-hernández/")); credistMenu.pacoButton.onClick.AddListener(() => Application.OpenURL("https://www.linkedin.com/in/francisco-rovira/")); for (int i = 0; i < colorMenu.colorButton.Length; i++) { int x = i; colorMenu.colorButton[i].onClick.AddListener(() => ButtonFunction(() => SetColor(x))); } colorMenu.returnButton.onClick.AddListener(() => ButtonFunction(ReturnColorMenu)); credistMenu.madeText.text = mainMenuText.creditsBody; credistMenu.andText.text = mainMenuText.creditsSecondBody; musicManager = FindObjectOfType <MusicManager>(); musicManager.PlayNewClip(musicManager.menuMusic); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A)) { Debug.LogInfor("Time=" + Time.realtimeSinceStartup + "Frame=" + EventCenter.Instance.CurFrameCount); TextAssetLoader loader = TextAssetLoader.LoadAsset(m_Url, m_LoadAssetModel, OnComplete); } if (Input.GetKeyDown(KeyCode.B)) { if (m_LoadAssetModel == LoadAssetModel.Async) { ResourcesMgr.Instance.LoadFileAsync(m_Url, (result) => { m_ShowText.text = result; }); } else { m_ShowText.text = ResourcesMgr.Instance.LoadFileSync(m_Url); } } }
/// <summary> /// 加载各种配置文件(配置文件只会被加载一次 ,加载后不会被主动销毁) /// </summary> /// <param name="url"></param> /// <param name="callback"></param> private void LoadFile(string url, LoadAssetModel loadModel, System.Action <string> callback) { TextAssetLoader.LoadAsset(url, loadModel, (loader) => { ResourcesLoadTraceMgr.Instance.RecordTraceResourceInfor(loader); #region 加载成功后的处理逻辑 if (loader == null || (loader.IsCompleted && loader.IsError)) { Debug.LogInfor("LoadFile Fail,Not Exit At Path= " + url); if (callback != null) { callback.Invoke(null); } return; } //加载资源出错 if (callback != null) { callback.Invoke(loader.ResultObj.ToString()); } #endregion }); }
public static TDataConfig CreateDataByPath <TModel, TDataConfig>(string csvPath, string scriptObjectPath, bool refresh = true) where TModel : new() where TDataConfig : DataConfigBase <TModel> { return(CreateDataByContent <TModel, TDataConfig>(TextAssetLoader.LoadInEditor(csvPath), scriptObjectPath, refresh)); }
public static ScriptableObject CreateColumnDataByPath(Type modelType, Type dataConfigType, string csvPath, string scriptObjectPath, string headerName, bool refresh = true) { return(CreateColumnDataByContent(modelType, dataConfigType, TextAssetLoader.LoadInEditor(csvPath), scriptObjectPath, headerName, refresh)); }