unityscript

Execution order within the Update() loop method in Unity3D

孤街醉人 提交于 2019-12-06 06:19:48
I'm trying to find the appropriate words to use to describe the issue that I am having, hopefully this will explain the problem. I have two Update() methods in two different classes, and some of the functionality in one is reliant on data from another. Code A is reliant on Code B's data, using Debug.Log() I found that Code B's Update() is being executed after Code A's Update() . My question is, Is there a out of box method to controller the Call stack of the Update method? If there is how is it done? If there isn't, does anyone have any technique that I could employ to resolve the problem. I

Convert Unity transforms to THREE.js rotations

邮差的信 提交于 2019-12-06 05:51:35
问题 How can I match the rotation of a THREE.js camera or object to a transform from a Unity GameObject? Unity uses a left-handed system with a ZXY euler order. THREE.js uses a right-handed system with an XYZ euler order. What transformations need to be made to convert GameObject.transform.rotation (Quaternion) to Object3D.rotation (THREE.Vector3)? 回答1: We ended up fixing this as follows: Assuming you get qx , qy , qz and qw from Unity's quaternion, we apply the conversion below in JavaScript /

FFMpeg Continuous Real-time Image to Video Encoding

假如想象 提交于 2019-12-06 05:00:26
问题 I am trying to use FFMpeg to take a stream of image files and turn them into a video. Now, I have successfully done this, but only after I have already captured all the images that I want. What I would like to do is turn the images into a video as they are saved to disk (real-time video recorder). Currently, when I call FFMpeg while frames are still being grabbed, it only encodes the number of images that are present when it is called. If FFMpeg is called every time an image is grabbed, it

ApplicationData.persistentDataPath Unity Editor to Android

末鹿安然 提交于 2019-12-06 02:26:59
Does anyone know, where do I have to place a file (sqlite file) in the unity project directory structure, in order to, after apk compilation and installation the file remains stored in the persistentDataPath at Android side? Thanks in advance! Directly inside Assets folder, create a folder with name "StreamingAssets" and put your sqlite database file in this folder then use the following code to extract and copy the sqlite database to persistentDataPath: void InitSqliteFile (string dbName) { // dbName = "example.sqlite"; pathDB = System.IO.Path.Combine (Application.persistentDataPath, dbName);

Multithreaded Script invocation in Unity3d

ε祈祈猫儿з 提交于 2019-12-05 20:42:08
I was trying to implement multithreaded script execution in Unity3d, but it seems that the there is no way provided by Unity libraries and we have to use System.Threading provided by Mono. But they have mentioned that Unity Scripting is not thread safe. Can i implement Multithreading safely and efficiently in Unity3D using System.threading or other Platform independent API ? Also how can i make sure that the scripts are running in parallel ? An example or a link would be highly appreciated. Regards I needed threading for an iOS application, unfortunately I never found a way to do such in Unity

How to check if a game object has a component method in Unity?

喜夏-厌秋 提交于 2019-12-05 09:58:45
I am writing a method to check if a gameObject has a component. Here it is: public static bool HasComponent <T>(this GameObject obj) { return obj.GetComponent<T>() != null; } And I'm using it like this: void Update() { if (Input.GetKey("w")) { if (gameObject.HasComponent<Rigidbody>()) { print("Has a rigid body."); return; } print("Does not have rigid body."); } } The gameObject does NOT have a rigid body but it is still printing that it does have. It is just... public static bool HasComponent <T>(this GameObject obj) where T:Component { return obj.GetComponent<T>() != null; } Note that you

Screen record in unity3d

一曲冷凌霜 提交于 2019-12-05 09:52:18
How to do screen record in unity? I want to record my screen(gameplay) during my running game. That should be play/stop , replay , save that recording on locally from device, open/load from my device (which is already we recorded). In my game one camera which can capture native camera, and one 3d model. I wish to record that both and use my functionality whenever i want. Thank you in advance. This is hard to implement, but not impossible. Because every frame or interval you need to capture screen shot of your camera view and store it in the list. You need good, (Smaller interval but not much.

Loading a .OBJ into Unity at runtime

99封情书 提交于 2019-12-05 06:19:17
My job is to write a code which loads a .OBJ into Unity in runtime. Unity has provided a sample code in it's wiki page. I used the following code to use the class given in the link: public class Main : MonoBehaviour { // Use this for initialization void Start () { Mesh holderMesh = new Mesh (); ObjImporter newMesh = new ObjImporter(); holderMesh = newMesh.ImportFile("C:/Users/cvpa2/Desktop/ng/output.obj"); } I'm not getting any errors in Unity Monodevelop, but neither is the model loaded. What may be the probable solution? Just creating a Mesh object is not enough. You will have to do at least

How to get contact points from a trigger?

拥有回忆 提交于 2019-12-05 04:50:30
I'm in a situation where I need a 2d sensor that will not collide but will also give me contact points for a collision. Triggers don't give me contact points and colliders give me contact points but cause a collision. I've tried disabling collisions when using colliders in the hopes of getting a collision enter callback but not having the collision actually occur, but no luck. So how do I get contact points from a trigger? Or how do I get a collision callback with rigidbodies without causing a collision? Basically I have a circle that I want to act as radar, but I'd like it to be fairly

FFMpeg Continuous Real-time Image to Video Encoding

醉酒当歌 提交于 2019-12-04 09:00:42
I am trying to use FFMpeg to take a stream of image files and turn them into a video. Now, I have successfully done this, but only after I have already captured all the images that I want. What I would like to do is turn the images into a video as they are saved to disk (real-time video recorder). Currently, when I call FFMpeg while frames are still being grabbed, it only encodes the number of images that are present when it is called. If FFMpeg is called every time an image is grabbed, it floods the CPU with a ton of processes. Ideally, FFMpeg would continue to encode the images until there