unity5

Unity: Need to reset a pooled object on return to pool. Perhaps using ScriptableObject?

对着背影说爱祢 提交于 2019-12-06 09:18:11
I have recently been trying out object pooling in unity to speed up the instantiation of several game objects at once. However, since these are fairly complex objects I need to reset them when they go back in the pool. I read that using ScriptableObject might be a good way to store the default values for an easy reset. But in order to do that I need to load a fresh ScriptableObject at runtime to store the actual values of the object. So in pseudocode, i'd have a class with public MyScriptableData data and public MyScriptableData defaults 1) create new pooled object with default

Writing RTL in input field

这一生的挚爱 提交于 2019-12-06 06:40:25
I'm trying to write Persian in unity input fields. Persian is right to left language and it's alphabet is similar to Arabic. I've found a library that converts and corrects the text. It's works just fine. When I'm showing the converted text into Debug.Log() everything is perfect but the problem is when I'm going to put corrected text into input field it would be reversed! I've tried to reversed the input field text but nothing happened! Here's my code public InputField empName; PersianMaker pm; string tempStr = ""; private void Start() { pm = new PersianMaker(); } void OnGUI() { tempStr = "";

Debug.DrawLine not showing in the GameView

半腔热情 提交于 2019-12-05 19:38:25
I'm working on a 2D Unity app and I'm encountering some weird behavior. This code works just fine. Debug.DrawLine(button1.transform.position, button2.transform.position, Color.green); When I run the app, I see a green line in the Scene view. But nothing appears in the Game view when I have the following line. Physics2D.Linecast(button1.transform.position, button2.transform.position); I'm confused as to how Unity is able to draw a line between these two buttons, but for some reason, it's just not doing it in the Game view. Any idea how I'd troubleshoot this? Programmer Just line Serlite said,

What is the most elegant way to let UI objects swallow touches in unity 5?

て烟熏妆下的殇ゞ 提交于 2019-12-05 16:53:08
My game uses unity 5 new UI system with canvas. The game itself can receive touches to shoot ammos via functions OnMouseDown() on several game objects with 2D colliders indicating touchable areas, and I can adjust the priorities of different touchable areas by changing the game objects' position.z. However with the UI added, any touches on UI elements (buttons, panels, etc.) will not only (if possible) trigger the UI elements, but they can also pass through UI elements and trigger the touchable areas. It's very weird when you press a button, not only the button is pressed, but also triggers

Loading new scene in background

ⅰ亾dé卋堺 提交于 2019-12-05 12:28:18
I'm creating a Unity application targeting the Samsung Gear VR. I currently have two scenes: The initial scene Second scene, with big quantity of data (it takes too much time to load the scene). From the first scene, I want to load the second scene in background, and switch to it once it has been loaded. While the new scene is loading in background, the user should keep the ability to move their head to see any part of the VR environment. I'm using SceneManager.LoadSceneAsync but it's not working: // ... StartCoroutiune(loadScene()); // ... IEnumerator loadScene(){ AsyncOperation async =

When does the LoadScene() function in Unity change the scene?

末鹿安然 提交于 2019-12-05 09:09:22
When you invoke the function LoadScene() does it immediately switch scenes, or does it simply signal that the scene needs to be changed? The documentation for LoadScene() does not say. The specific example I am working with looks like this: LoadScene(levelName); ItemBox newBox = (ItemBox)Instantiate(...); So with the above code, would the newBox exist in the scene we just loaded, or would it get created in the old scene, then destroyed when the new level is loaded. It's UnityEngine.SceneManagement.SceneManager.LoadScene("Gameplay"); and yes it does it "instantly" -- that is to say s

Unity How to change the Rendering Order of A canvas

故事扮演 提交于 2019-12-05 08:57:19
I'm using unity 5.3 and I'm trying to change the Rendering Order of two overlayed cross platform controls which each reside in their own canvas. In previous versions you could bring the window into focus using GUI.FocusWindow(0); However this does not work with the new system. I've also tried modifying the order in the editor window which has done nothing. Does anyone know how I can move a control to be on top of the other? After doing some research I found the proper way to change the Canvas Rendering Order. There is a property in the Canvas for the Sort Order, which is really the render

GameObject update order in Unity

本小妞迷上赌 提交于 2019-12-05 02:27:02
问题 The Unity Manual describes the order in which the Script functions are called. However, I was wondering if there were any rules regarding the order in which the GameObjects themselves are considered in Unity. GameObjects are basically the nodes of Unity's scene graph and (assuming the scene itself was the root node) they form a tree. I was wondering if that tree structure imposed any rules on the order in which GameObjects are considered. As already mentioned, the manual describes that Awake(

UNET Multi-Player game, having both players interact with gameObject, changes synchronized on host and client

此生再无相见时 提交于 2019-12-04 17:40:09
I want to create a simple demo. I want there to be a cube, in the middle of a plane, that changes colors when you click it. (This was easy to implement) I want there to be two players, who take turns clicking the cube. The cube will only change colors if it is your turn. If the cube changes colors, the change will reflect on both the players' screens. I've been looking at the examples for UNET, http://forum.unity3d.com/threads/unet-sample-projects.331978/ , and most of them have a networked character who you control with your keyboard, and this aspect is throwing me off. Do I still need to

Unity android project throws “Your hardware does not support this application sorry” error

陌路散爱 提交于 2019-12-04 14:49:29
问题 I have been investigating for 2 days. I have read a lot of things. To summarize what I read: Non-NEON devices will not work with UNITY 5 builds. You should set your Install Location to "Automatic or Force Internal" You should set your Write Access to "Internal Only" Along with the above ones, I also tried with these texture compression settings: Don't override DXT (Tegra) Also there are two cases that I tried: When I built the game from UNITY and generate an apk. It worked fine on the phone.