unityscript

how to add gaze input timer to trigger an action after gazing for 3secs?

笑着哭i 提交于 2019-12-08 02:25:38
问题 I am new to unity and VR. I have been using google cardboard SDK to create VR apps in unity and am stuck at gazetimer. I want to trigger an action only if the user looks at any object for 3secs but have not been able to do so. Please help 回答1: Please see a similar question and answer here Use Gaze Input duration to select UI text in Google Cardboard In summary, create a script to time the gaze, by cumulatively adding Time.deltaTime on each frame when the object is gazed at. When gaze time

Execution order within the Update() loop method in Unity3D

夙愿已清 提交于 2019-12-08 01:54:38
问题 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

ApplicationData.persistentDataPath Unity Editor to Android

好久不见. 提交于 2019-12-07 16:52:02
问题 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! 回答1: 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

Screen record in unity3d

ε祈祈猫儿з 提交于 2019-12-07 06:24: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. 回答1: This is hard to implement, but not impossible. Because every frame or interval you need to

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

北战南征 提交于 2019-12-07 04:07:20
问题 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. 回答1: It is just... public static bool

How to get contact points from a trigger?

跟風遠走 提交于 2019-12-07 01:46:42
问题 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

Textures loads in editor but not in standalone (appears pink)

坚强是说给别人听的谎言 提交于 2019-12-06 15:45:22
I'm using an asset named Simple Obj , that allows me to import an obj, their materials and the textures associate . This works fine in my editor but not in my standalone. My OBJ are not in my resources file , I take it from another file with the WWW method. Here's how I do it, t his download my OBJ, create a Gameobject and place it in my scene : private IEnumerator DownloadAndImportAllInBackground(string url, Plane newPlane) { string objString = null; string mtlString = null; Hashtable textures = null; GameObject planeObject = null; bool gameObjectPerGroup = false; bool subMeshPerGroup = false

Unity LookAt 2d Equivalent

為{幸葍}努か 提交于 2019-12-06 08:54:25
I'm creating a tank fighting 2D game top-down in Unity 3D in the 2D perspective active. My axises are X and Y (defaulted) and I'm trying to create a homing missile My missile code is code is: var enemyName :String; // which enemy does this shot seeks private var target :GameObject; var speed :float = 100; private var timeToTarget:float; function Start () { timeToTarget = Mathf.Abs(speed); if (timeToTarget<=0) { timeToTarget=150; } target = GameObject.Find(enemyName); Destroy(this.gameObject, timeToDie); myTransform = transform; } function Update () { rorate2target(); follow(); } function

how to add gaze input timer to trigger an action after gazing for 3secs?

蹲街弑〆低调 提交于 2019-12-06 07:38:32
I am new to unity and VR. I have been using google cardboard SDK to create VR apps in unity and am stuck at gazetimer. I want to trigger an action only if the user looks at any object for 3secs but have not been able to do so. Please help Eugene Sia Please see a similar question and answer here Use Gaze Input duration to select UI text in Google Cardboard In summary, create a script to time the gaze, by cumulatively adding Time.deltaTime on each frame when the object is gazed at. When gaze time hits a pre-specified duration, trigger the button's OnClick event. On the object, activate the

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 = "";