Hot answers tagged

2

I would recommend you to use the same class for generation and for usage of the Grid, because, firstly, it is the same objects you are working with, secondly, because you can avoid usage of Update() for now: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Grid : MonoBehaviour { public GameObject gridPrefab; ...


2

The documentation for allowSceneActivation reads: When allowSceneActivation is set to false, Unity stops progress at 0.9, and maintains isDone at false. When AsyncOperation.allowSceneActivation is set to true, isDone can complete. While isDone is false, the AsyncOperation queue is stalled. So Unity intentionally doesn't let the load operation finish if ...


1

Did you mean GetComponentInChildren, without the "s"? When you use the plural, you're saying "give me ALL the cameras you find," so it has to return an array Camera[] to hold potentially multiple cameras. When you use the singular, you're saying "give me the FIRST camera you find," so it's able to return either a single valid ...


1

I still have not figured out what this is causing this, at least it is possible to force the game to use the correct resolution by just setting the resolution back. void Start() { Screen.SetResolution(2240, 1080, true); } https://docs.unity3d.com/ScriptReference/Screen.SetResolution.html


1

Will switching this to use lazy initialization help? // No OnEnable method anymore. Instead, when a sprite UV is requested, // we check whether we've loaded all the sprite texture coordinates, // and if not, then we load them "just in time". public Vector2[] GetUVsForBlockType(BlockType blockType) { if (_blockTypeToTextureCoordinates.Count == ...


1

This should work: private void Test() { for (int x = 0; x < gridHeight; x++) { for (int y = 0; y < gridWidth; y++) { blocksX.Add(x.ToString()); blocksY.Add(y.ToString()); int index = y + x * gridWidth; texts[index].text = x.ToString() + ", " + y.ToString(); } ...


1

You could add inside the CreateGrid(): if (Random.Range(0,2)==0){ var blockRenderer=GridBlocks[0,Random.Range(0,GridHeight)].GetComponent<Renderer>(); blockRenderer.material.SetColor("_Color", Color.blue); blockRenderer = GridBlocks[GridWidth-1,Random.Range(0,GridHeight)].GetComponent<Renderer>(); ...


1

I don't know if it'll work for your specific use case, but note that there's the PostProcessBuild attribute for editor scripts that run automatically after a build. I use that to edit the XCode project generated by an iOS "build". Another approach is to write a script that executes the build, and that script can probably do cleanup after a build ...


1

It's not possible to answer this question as written, as we have no idea what APIs you're using, and what's changed in the different versions of Unity. I recommend making a backup of your projects, then get the latest version of Unity listed for LTS (Long Term Support... these versions get 2 years of fixes and updates, meaning you can get updates to that ...


1

I found a solution. I don't think it would be the best but it works for now. With the new input system I subscribe A function (OnTransferKey) to a Key Press void OnEnable() { uI_Manager.uIInputManager.Inventory.OnTransfer.performed += OnTransferKey; } void OnDisable() { uI_Manager.uIInputManager.Inventory.OnTransfer.performed -= OnTransferKey; } ...


Only top voted, non community-wiki answers of a minimum length are eligible