Menu
  • HOME
  • TAGS

Coroutine being detected as inactive despite being active

c#,unity3d

StartCoroutine is a method of MonoBehaviour. So, whichever script actually uses StartCoroutine is actually the object that needs to be active. You may want to try oldAnimal.StartCoroutine(oldAnimal.Flash());...

Controlling a player using touch input on the mobile device

android,ios,mobile,unity3d,touch

Your trying to call HitTest directly from GUITexture like a static function but HitTest isn't a static function, you need to create a variable from GUITexture class and then call HitTest function from that object like this: public GUITexture guiT; if (guiT.HitTest(touch.position) && touch.phase !=TouchPhase.Ended) { guiT.texture = button2; transform.Translate(Vector3.right*30*Time.smoothDeltaTime);...

Unity3d AudioSource not creatable

c#,audio,unity3d

This is perfectly natural C#, but it won't fly: sct=new AudioSource(); Unity has a component-driven, factory-based architecture. Instead of calling a component constructor, Unity wants you to call AddComponent to attach the component to a specific GameObject: sct = gameObject.AddComponent<AudioSource>(); There are a few reasons for that. First off, Unity...

AdColony's OnVideoFinished not call in Android

c#,android,unity3d,adcolony

This is a known issue at AdColony and we will be releasing a fix in a pending release. We will update this post once it has been released at: https://github.com/AdColony/AdColony-Unity-SDK...

Retrieving data from a database in another thread(Unity3D)

c#,multithreading,unity3d

It finally works now. Just had to add these in retrievefromDB() public void retrievefromDB(){ while(true){ if (timeStep - prevTimeStep > 99) { timeStep -= 1; //special for this dataset query = "SELECT * FROM GridData2 WHERE timestep=" + timeStep; if (showParent) query += " AND (Level != 10)"; else query...

Call methods on fields of specific class

c#,unity3d

Well, since you wrote Items are not going to be dynamically added or removed at runtime. I would suggest creating another field that will be collection of items, and populate it in the constructor of the container class using reflection. Then, in the UpdateAllItems() method you can iterate this collection...

Unity 5.1 and OnGUI()

user-interface,unity3d

Your Code clearly Saying KeyCode.Escape and not getting space key change that to KeyCode.Space and it'll work

AppWarp RoomID in Unity SDK

android,unity3d,multiplayer,appwarp

After you connect to AppWrap API using your API key and Secret key (I don't think you should show us those keys in your picture you better remove them) your should create a room or a lobby yourself to interact with other players in it. consider reading Standard User Guide...

Why is my Rigidbody != null immediately after seeing that it is null?

c#,generics,unity3d,null

From other research (Equals(item, null) or item == null and Unity Forums) and to elaborate on usr's answer: I needed to guarantee that a Component was being passed through in my CheckIfNull header. The updated code looks like this: using UnityEngine; using System.Collections; public class NullChecker : MonoBehaviour { void...

EditorGUILayout.Popup option is not changing

unity3d,unity3d-gui,unity3d-editor

don't use "selected" AND "criteria". you must use the same ONE variable: int selected = 0; ///* string[] options = new string[] { "Start With", "End With", "Contains", }; //selected = EditorGUILayout.Popup("Search Criteria", 2, options); //*/ selected = EditorGUILayout.Popup("Awesome Drop down:", selected, options, EditorStyles.popup); because this is the way your...

Crash EXC_CRASH (SIGABRT) unity + vuforia + ios

ios,unity3d,vuforia,ios8.3

Okay, from your Question, it looks like you've checked on Multithreadingin your Build Settings? Disable that, I really doubt you'll have the need to use it. From the picture in your comment, you seem to have used Architecture - Universal. Instead, change that to ARMv7 and as per your question...

Android - Unity3D freeze in splash screen on some phones

android,unity3d,screen,freeze,splash

Okay , I found the solution. It turns out that one of my script was responsible for this problem. So I deleted it and rewrite another script that do the same job. I assume, script was trying to use RAM over and over , so because of that, Adreno 330...

Unity - Gui Button issues (Android)

c#,android,button,unity3d

I figured out the reason all my boosts got used in one go, I was using RepeatButton instead of Button. Although this didn't work at first I combined it with (&& boosts > 0) and it now works perfectly :) public void OnGUI() { if (GUI.Button(new Rect(20, Screen.height - 150,...

Using Unity to plot 3d geometry with sin & cos

c#,unity3d

You need to draw a curve... X,Y,Z components of your curve is coming from the equation you have possibly with sin and cos and then you need to draw a curve by sampling the curve with small increments and connect the samples with lines... This tutorial gives you a good...

Loading MP3 files at runtime in unity

c#,unity3d

As noted above, windows doesn't support MP3, so use OGG or WAV. You must wait for WWW to complete before accessing the clip. And WWW must be loaded in an asynchronouse Coroutine. public void LoadSong() { StartCoroutine(LoadSongCoroutine()); } IEnumerator LoadSongCoroutine() { string url = string.Format("file://{0}", path); WWW www = new...

Using Switch for Simple Unity3D Patrol Movement

c#,unity3d,switch-statement

This is how I would do it if I really wanted to use the switch statement: float someSmallValue = 0.5f; // Adjust this as per your needs if (Vector3.Distance(transform.position, patrolPoints[currentPoint].position) < someSmallValue) { switch (moveType) { case MoveType.Forward: currentPoint++; if (currentPoint > patrolPoints.Length - 1) { currentPoint -= 1; moveType...

Scoring scale object

unity3d

this is very simple. use one image as the scale background. use another image as the pointer. set the pivot and anchor of the pointer at the position where you want to rotate it. use transform.Rotate() in your code to rotate the pointer.

Unity3D Play sound from particle

audio,unity3d,collision,particles

You can use OnParticleCollision and the ParticlePhysicsExtensions, and play a sound with PlayClipAtPoint: using UnityEngine; using System.Collections; [RequireComponent(typeof(ParticleSystem))] public class CollidingParticles : MonoBehaviour { public AudioClip collisionSFX; ParticleSystem partSystem; ParticleCollisionEvent[] collisionEvents; void Awake () { partSystem = GetComponent<ParticleSystem>(); collisionEvents = new ParticleCollisionEvent[16]; } void OnParticleCollision (GameObject other) { int safeLength...

Giving objects unique ids onStart

c#,random,unity3d

Unity already provide an unique id for every object instance, have a look at GetInstanceID.

How to check button clicked in new UI button of unity 5.0

button,unity3d

Add an Event Trigger component to your button . From there you can add a listener for OnPointerUp for when mouse is released and OnPointerDown for when mouse is pressed

Unity3D 5 packages conflict

unity3d,google-play,package,admob

First make a backup of your project and delete your metadata files in your asset project folder and childs. Files with extension .meta

Best way to get variable from another script

c#,class,unity3d

Do not have multiple speed variables, just have one, and call for it every time you need to get it SpeedHolder speedHolder; public void Update() { transform.position += speedHolder.Speed * Time.deltaTime; } If you REALLY want this done another way... you can use events and delegates. public class SpeedHolder {...

Changing the length of a line renderer using DOTween

unity3d,tween

Why not just tween it yourself? float x = 0f; IEnumerator TweenLinerenderer() { while(x <= 1f) { myLineRenderer.SetPosition(1, new Vector3(x, 0, 0)); x += Time.deltaTime; yield return null; } x = 0f; } ...

2D game development with Unity3D

unity3d,2d-games

You won't need to purchase any licencing for those platforms. You will need to start paying when your annual turnover is high enough but I doubt you have to worry about that now. See here: https://unity3d.com/get-unity. Unless you make $100 000 a year off of Unity then you can deploy...

Controlling/moving an object in a circular motion in Unity

c#,unity3d,rotation,position

float timeCounter = 0; void Update () { timeCounter += Input.GetAxis("Horizontal") * Time.deltaTime; // multiply all this with some speed variable (* speed); float x = Mathf.Cos (timeCounter); float y = Mathf.Sin (timeCounter); float z = 0; transform.position = new Vector3 (x, y, z); } ...

Our iOS developer has developed a game in Unity3D. How do we export it for Android?

unity3d

If you are asking about "one click export for Android" then yes it is a one click export for Android Build Settings > Android > Switch platform > Build But for the question will there be any additional work necessary. Well that depends if you have used any (self made...

Manual slide-in animation using delta time

c#,animation,unity3d

If you really want to be frame-rate independent you should use a coroutine that's how i'd do it : float startWidth = 1f; float endWidth = 10f; float startPosition = 1f; float endPosition = 10f; float positionX, widthX; IEnumerator SlideInAnimation(float slideTime = 0.3f, float expandTime = 1f) { float t...

Unity: Prefab parenting in code

unity3d,gameobject

Are you sure you want to Instantiate 10 child prefabs on each frame (Update is called once per frame). I think you problem is, that you did not Instantiate the parent prefab. If I take your code, and fix it, it works like a charm for me. public GameObject childPrefab;...

Csproj file in unity changes everytime i reload the project

c#,unity3d,msbuildcommunitytasks

As far as I know, you cannot prevent Unity from overwriting your csproj files upon recompilation of your scripts. When working with larger code bases and Unity3D I tend to put most of my code into separate .Net assemblies (DLLs). This helps me when I'm sharing code between multiple projects...

Unity: Android and iOS Push Notifications

android,ios,unity3d,push-notification,android-notifications

You are right, someone has done that indeed :) I'm one of developers of the new Unity asset UTNotifications. It does all you need and even more. Please also note that there is no single way to implement the Push Notifications to work with any Android device - there is...

Create array/list of many objects(initially unknown amount) by tag

c#,arrays,list,unity3d,gameobject

public List<GameObject> myListofGameObject = new List<GameObject>(); Start(){ myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName")); myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName2")); myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName3")); foreach(GameObject gc in myListofGameObject){ Debug.Log(gc.name); } } Works Perfectly fine for me, Make sure to add the System class for linq generics....

Make two physics objects not collide but do detect collisions in Unity

unity3d,2d,physics

Yes, you need to create a child GameObject, with a trigger collider, and put it in a layer that interacts with the player layer. No, you don't need to add a Rigidbody to the new GameObject, the parent's rigidbody already makes it a dynamic collider, so you will get OnTrigger...

Unity setting GUIText of another object

c#,unity3d

if you have gameController = GetComponent<GameController> (); make sure that PlanetController and GameController are actually on the same game object in your scene. if they are not, you will have to use: http://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html...

How to make the whole scene in dark on unity3D

unity3d

Create a GUITexture object: in unity menu: GameObject -> Create GUI Texture, let’s call it darkBackground; Attach a dark texture to darkBackground; Disable darkBackground object (you can do it interactively or programatically call) darkBackground.SetActive(false); When paused, turn on /enable this GUITexture game object by calling darkBackground.SetActive(true); ...

Unity WebPlayer “Failed to initialize player's 3D settings”?

web,unity3d,3d,augmented-reality,unity-web-player

Try this. Furthermore, I would just uninstall everything and just reinstall with a stable version of Unity 5.

Convert a large int to a float between 0.0f and 1.0f

math,unity3d,numbers

You can take your number that ranges from 0 to 500 and simply divide it by 500, e.g. scaled_x = x / 500.0f. Depending on the language and the type of x you will need to divide by either 500 or 500.0f. If you are using a language that has...

Having data virtualization in Unity3d UI panel

unity3d,panel

When you describe it that way, its much clearer & much simpler. Look at any mobile application: they do not put 6000 people records on a single page. Its normally paged or grouped, with a search option. So do that instead. If you look at the facebook mobile app (a...

Prevent Construction of object using new()

c#,unity3d,new-operator

In plain vanilla C#, it is not possible for the new operator to return null. It will either return a valid non-null reference, or it will throw an exception. Note, however, that Unity is not "plain vanilla C#". Unity is based on Mono (which in turn is based on .NET),...

Unity 5 Audio Volume Slider (Solved)

c#,audio,unity3d

The master volume control in Unity is owned by the AudioListener Your code is updating a saved value in PlayerPrefs called VolumeLevel, but it doesn't actually tell Unity to change the volume at any point. To do that globally (i.e. for all sounds at once), you can update AudioListener.volume with...

Unity2D C# - Can't destroy an Instantiated object

c#,unity3d

You must instantiate prefabs like this. PrefabTypeObject obj = (TypeOfPrefab)Instantiate(prefab, position, rotation); or PrefabTypeObject obj = Instantiate(prefab, position, rotation) as TypeOfPrefab; otherwise you will get null object or InvalidCastException like now. Your solution is` clone = (GameObject)Instantiate(swordObject_prefab.gameObject, Player.position, Quaternion.identity); ...

Shooting a ball (With gravity)

c#,unity3d

So I am struggling with how to figure out how to make the ball shoot in the direction it is facing depending on how it have been translated in the ball script. Multiply speed by the direction you want to shoot in: // Shoots a ball the longer you...

How to access RectTransform's left, right, top, bottom positions via code?

unity3d,unity3d-gui

Those would be RectTransform rectTransform; /*Left*/ rectTransform.offsetMin.x; /*Right*/ rectTransform.offsetMax.x; /*Top*/ rectTransform.offsetMax.y; /*Bottom*/ rectTransform.offsetMin.y; ...

Unity - Particles emitting non-random

unity3d,particle-system,particle,trail

If you just want to control the direction, using a mesh definitely works. Particles are emitted from the mesh (be it from a vertex, edge or triangle) using the mesh's normal at that point as direction (unless Random Direction is checked), so make sure the mesh's normals are in order....

I'm trying to reduce the Length of this Code

c#,unity3d

You could use Math.Min and Math.Max. minXvert = Math.Min(verts[i].x, minXvert); maxXvert = Math.Max(verts[i].x, maxXvert); That would make your code more concise and readable, but won't make it any faster. To make it somewhat faster, you could store x, y, z values in local variables, so they only have to be...

Unity3D Bullet Tracers

unity3d,unityscript,raycasting

Quaternion.LookRotation((fwd - transform.position).normalized) needs to be Quaternion.LookRotation(fwd.normalized)

Unity c# List memory leak

c#,list,memory-leaks,unity3d

Apparently this is a bug with Texture2D.Apply(). It's so deep, Unity's profiler did not show the leak, but external tools did. Unity have acknowledged the problem and are seeking out a solution. No date was given. Thanks for the help :-)

Constant animation hapenning when moving

c#,unity3d

How about this way? bool _isAnimating = false; // Update is called once per frame void FixedUpdate() { if (Input.GetMouseButtonDown(1))//If clicked { clickPosition(); //Gets the click position //start animation here!!! //animator.SetBool("bWalk", false); //and set animation state to true _isAnimating = true; } if (Vector3.Distance(transform.position, mouseClick) > minDistance) { clickToMove(); }...

how to add Scoring to unity3D 2d top down car game?

unity3d,2d,car,topdown

Since this is a racing game, time to complete the race would be your main scoring factor. The faster the player finishes the race the higher the score. As for your question about passing enemy car you can check that by calculating the distance the player has covered on the...

Turning an avatar into a 3rd person character

animation,unity3d

That article gives a good overview of what is required. However, you can essentially skip almost all those steps when using autodesk character generator. Here is a quick way: Set your FBX to be a mecanim humanoid Drag an mecanim animator controller onto it Write your code to set the...

Unity WaitForSeconds stuck

c#,unity3d

Your code is perfect. That means one of 2 things: DelayTime is excessively large (debug it out) or, more likely: The GameObject is destroyed so the CoRoutine nolonger is running. Try this: void Start () { guiTexture.pixelInset = new Rect (0, 0, Screen.width, Screen.height); StartCoroutine (LoadNextScene ()); } IEnumerator LoadNextScene(){...

What is this programming method called? And is it bad?

c#,unity3d,modular

This is essentially a Service Locator "Anti Pattern" that is (surprise surprise) based around the Singleton Pattern. However, instead of retrieving service instances, you are retrieving object instances. Regardless of the name, this actually does NOT create a more modular application. On the contrary, you are creating hard dependencies throughout...

Why i can't see Fixed Angle option in Rigidbody2D in the new Unity5?

unity3d

In Unity 5.1, the fixed angle effect is done via Rigidbody2D.constraints. GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; See also RigidbodyConstraints2D....

When building to mobile the size of fonts reduce and became very small

c#,user-interface,unity3d,uibutton,unityscript

At a guess, your Canvas' CanvasScaler's UI Scale Mode is probably set to Constant Pixel Size, and if your mobile device's resolution is too high, text will appear small. Try changing the UI Scale Mode to Scale With Screen Size and change the properties it provides as needed. (if your...

Unity procedural TileMap generation without creating gameobject per tile

unity3d

Given the sole task of "creating an efficient tilemap", your best option is to create a TileMap component that manages a procedural mesh made up of a collection of independent quads with uvs mapped to a tile atlas. This way you will even draw your whole map in one drawcall....

How to Create Thumbnails in unity

unity3d

When using the new UI objects, as opposed to the Legacy GUI, you must have the image imported as Sprite/UI. Unity Import Reference...

ant jar error: Execute failed: java.io.IOException: Cannot run program…${aapt}": error=2, No such file or directory

java,android,osx,unity3d,jar

Have you updated the Android SDK tools to 24.3.2? This seems to have caused the issue. Add following 4 lines to android-sdk-path/tools/ant/build.xml starting line 484 and hopefully it should solve. <property name="aidl" location="${android.build.tools.dir}/aidl${exe}" /> <property name="aapt" location="${android.build.tools.dir}/aapt${exe}" /> <property name="dx" location="${android.build.tools.dir}/dx${bat}" /> <property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" /> ...

Unity3d get Mouse Input Axis

c#,unity3d,mouse

is the mouse in unity "captured" in screen resolution or how should I scale the mouse Position to a value between -1 and 1 ? In this case the "normalizedSpeed" will be your target public float mouseDistance; public Vector2 mouseDown = -Vector2.one; public float normalizedSpeed; public void Update() {...

SWF works locally but not loaded from server

mod-rewrite,unity3d,swf,swfobject

I did some further tests, sadly there are no errors on the console. But it pretty much looks like there's something wrong with your .swf file on the server, because when I download the file from your server it is not working locally either. (Did you try that before?) How...

Unity: GameObject.FindGameObjectWithTag isn't working and I don't know why

unity3d

if (sResult = null) { Should be if (sResult == null) { Single = is an assignment operator so you are setting the result to null instead of checking if it is null....

unity add component (triangle) not working

c#,unity3d

Lowercase your GameObject to gameObject. GameObject is a type, gameObject is a reference to the attached GameObject. Also you are adding the MeshFilter twice, that is a mistake. Cache your components so you can use them later like this: EDIT: thought your "GetComponent" was another "AddComponent". So i retract my...

Unity3D: Adding force based on direction an object is facing

c#,unity3d,transform

Try this: void shootIt() { Vector2 direction = transform.localPosition.normalized; transform.parent = null; isPlaying = true; A.isKinematic = false; A.AddForce(direction*varSpeed*_multiplier); } Also consider forcing yourself to write good names for your variables. A is not very descriptive....

Why am I getting the following error when compiling this assembly?

c#,unity3d,mono,.net-assembly

The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below). This is verified by opening up the assembly in your reflector tool of choice, here I...

Instantiate GameObject at Random time is not working

unity3d

seems like inside Update you are missing a '=' Ie: if (Spawn1 = true) Should be: if (Spawn1 == true) Also to avoid extra processing on Update method you can do this: void Start () { StartCoroutine( AutoSpam() ); } void Update () { // Empty :) } IEnumerator AutoSpam()...

Unity3D: Moving a child to orbit a parent

c#,unity3d,position,transform

whenever I move the parent of the object, the child stays and no longer moves around the parent Thats because you are moving the sphere via transform.position when it should be transform.localPosition Either that or you could do transform.position = transform.parent.position + new Vector3 (x, y, z); EDIT: personally,...

Integrating Unity3d into iOS UITabbarController / UINavigationController

ios,objective-c,xcode,unity3d

So after many days of researching and testing hope my answer will help someone who is facing this problem. Assuming you integrated unity with your project and there is no compiling errors. There are 3 files you have to modify in order to get this to work. I’m using Unity...

Does the game engine allow me to intergarte native android code

android,unity3d,libgdx,andengine

It is possible in andEngine to start andEngien activity from basic android activity and the other way: to start normal android activity from andEngine game. You can find examples on StackOverflow. Try to search for "Trouble launching Andengine Activity from OnClickListener" (Sorry, cant paste links right now). Also, isn't it...

How do I convert point to local coordinates?

c#,user-interface,button,unity3d

Thats exactly why you dont find the location of the point inside of the button itself... but you compare the location of the point inside of the parent rect of the button and the buttons localPosition itself. That or you can translate the pixel point to screen position then compare...

How to scroll to a specific element in ScrollRect with Unity UI?

user-interface,unity3d,unity3d-gui

I am going to give you a code snippet of mine because i feel like being helpful. Hope this helps! protected ScrollRect scrollRect; protected RectTransform contentPanel; public void SnapTo(RectTransform target) { Canvas.ForceUpdateCanvases(); contentPanel.anchoredPosition = (Vector2)scrollRect.transform.InverseTransformPoint(contentPanel.position) - (Vector2)scrollRect.transform.InverseTransformPoint(target.position); } ...

Unity | 'gameobject.renderer.material.color' in version 5.x

unity3d,shader,crop,mask,renderer

Make a global variable MeshRenderer renderer; Start() { renderer = gameObject.GetComponent<MeshRenderer>() as MeshRenderer; } now you can use renderer!...

converting string to vector in Unity

vector,unity3d,unityscript

I figure someone else might find this useful later so: if(PlayerPrefs.GetFloat("nodeNum") > 0) { //Assemble axis value arrays //X var xString = PlayerPrefs.GetString("xVals"); var xValues = xString.Split(","[0]); //Y var yString = PlayerPrefs.GetString("yVals"); var yValues = yString.Split(","[0]); //Z var zString = PlayerPrefs.GetString("zVals"); var zValues = zString.Split(","[0]); var countNode = 0; var...

Unity An object reference is required to access non-static member C#

c#,unity3d

You need to instantiate your class Rigidbody before accessing a non-static field such as AddForce. From the documentation bellow : using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public float thrust; public Rigidbody rb; void Start() { // Get the instance here and stores it as a class...

I cant get custom GUIskin to work

c#,unity3d

I don't see where you've declared your GUI Skin in the code above. using UnityEngine; using System.Collections; public class InfoInput : MonoBehaviour { public string charname = "Name"; public string usrname = "User Name"; public string charrace = "Race"; public string charclass = "Class"; public string charalli = "LG"; public...

Press one button, focus all buttons

c#,unity3d

GUI.color = Color.black; makes every button's alpha color higher...

In Unity3D, How to make the whole scene in dark, but some Area are not in dark

unity3d

I'll explain how you can achieve this with a simple shader and some setup. I'm speaking from memory so if some problems occur please ask. So what you can do is: Make a new layer for rendering the masks. Let's say we call this layer MaskLayer. Duplicate your main camera....

Formatting large numbers in C#

c#,.net,unity3d,formatting

I am using this method in my project, you can use too. Maybe there is better way, I dont know. public void KMBMaker( Text txt, double num ) { if( num < 1000 ) { double numStr = num; txt.text = numStr.ToString() + ""; } else if( num < 1000000...

Delete animation of a certain bone for a number of frames Unity3d

unity3d,unityscript

Comment is getting Bigger So I will paste it in here. https://www.youtube.com/watch?v=Xx21y9eJq1U In this video try to check the 44:51 ish or something. That is what you need. Then Control it with a script when to activate it. It is a Masking. You can mask the animation and so on....

Unity 3D scripts move multiple objects

c#,unity3d

private GameObject Gobj; is a variable for a single GameObject. Reformat it to private List<GameObject> objects; and instead of Gobj.transform.position = new Vector3 (ObjPosition.x, ObjPosition.y, ObjPosition.z) do this: foreach (GameObject item in objects) { item.transform.position = new Vector3 (ObjPosition.x, ObjPosition.y, ObjPosition.z) } EDIT: In case you aren't sure about how...

How expensive is creating class instance? (performance considerations) [closed]

c#,unity3d

I remember reading a fun post Performance numbers in the pub by Ayendy Rahien. How many CLR objects can you create in one second? And here was the result back in 2011 Created 7,715,305 in 00:00:01 Jokes aside. Create is pretty cheap operation but GC is not. So while you...

How do I Mute The Audio In Unity 3D?

c#,audio,unity3d,mute

Simply google it, the following is from: http://answers.unity3d.com/questions/52109/how-do-i-mute-all-audio-sound.html AudioListener.pause = true; AudioListener.volume = 0; try this http://unity3d.com/support/documentation/ScriptReference/AudioListener-pause.html...

Iterating through multiple levels of Child Objects

c#,unity3d,iterator

The way you wrote it is actually exactly how you want to do it. The method is called recursion. It is a very popular way of achieving what you are trying to do, nothing wrong with having a method calling itself, if done within certain guidelines like meeting certain criteria...

How do I detect if a sprite is touching another sprite

c#,unity3d

You should attach the script that contains oncollisioneneter to your sprite1 game object for example and in your sprite 2 game object add a tag like sp2 or whatever you want , then in your script when collision happens you check if the object that sprite one collided with is...

Unity 3D Text becomes Word Cubes

android,unity3d,vuforia

Your problem is having a MeshFilter on the same GameObject as your TextMesh What you are seeing is the MeshRenderer drawing the wrong mesh, but using the font's material. Those seemingly random letters is what a font texture atlas actually looks like when textured on a cube. What mesh is...

Input disabled after moving object in editor while in “play mode”

unity3d,unity3d-editor

I think that's because when you move the object, the Unity GameView will lose its focus. So just ensure it has the focus again (klick into it), before hitting the key.

Unity Cardboard on Nexus 6 bug: U.I of previous scene is remained on view when new Cardboard scene is loaded

android,unity3d,google-cardboard

I solved the bug myself. This issue was solved by updating my Unity 5 Pro to v5.1.0f3 and Cardboard SDK for Unity v0.5....

Using Project Tango Unity example projects

android,unity3d,google-project-tango

The example code is Unity 5 based project, so please use the 5.x version of Unity to open it. If you use Unity 4.x version, the scene won't be opened up properly. However, the code lab is based on Unity 4.6 and it is independent from our sample code. I...

Unity3d - Input.GetKey returns true more than once

c#,unity3d,event-handling,keyboard

Please refer to http://docs.unity3d.com/ScriptReference/Input.GetKey.html Returns true while the user holds down the key identified by name. Think auto fire. If you look at the input class you can find other functions which will be more useful....

How to draw each a vertex of a mesh as a circle

ios,unity3d,shader,mesh,particle

You can do it using geometry shaders to create billboarding geometry from each vertex on the GPU. You can then either create the circles as geometry, or create quads and use a circle texture to draw them (I recommend the later). But geometry shaders are not extensively supported yet, even...

Reserve Ammo Formula

unity3d,fps

Your code explicitly creates ammo with that if statement, as you are turning negative myReserve values into zero. Let me refactor your code, this is exactly what you code does now: var transferedAmmo = magSize - boolet; myReserve -= transferedAmmo; boolet += transferedAmmo; if (myReserve < 0) myReserve = 0;...

Mesh tilemap and scrolling

c#,unity3d,game-engine,mesh,tile

if you want to scroll uv`s , you can do it by changing the texture offset in Update method , it can be used for background of a 2d game using UnityEngine; using System.Collections; public class ScrollingUVs : MonoBehaviour { public int materialIndex = 0; public Vector2 uvAnimationRate = new...

Converting from Pixel Coordinates to UI Coordinates in Unity

user-interface,unity3d

Image img = null // I assign it via the inspector void Update() { if(Input.GetMouseButtonDown(0)) { Vector2 point; RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)img.rectTransform.parent, Input.mousePosition, canvasCamera, out point); img.rectTransform.anchorPosition = point; } } ...

Unity3D: Adding charged force in relation to position

c#,unity3d,position,transform

It's been awhile since I've did Unity coding, so there may be some minor errors with my syntax but it should give you an idea of how to accomplish this. Your best bet for the loop is to use a coroutine to not block the main thread. in Update() check...

var keyword vs actual type? [duplicate]

c#,unity3d

var means the compiler will determine the explicit type of the variable, based on the usage. One pro is that it requires less typing to declare variables and it's more readable, but can be used only for local scope variables. Also with var, you don't have explicit reference to type,...

Unity OnMouseEnter not working

c#,unity3d

The Background gameobject in the scene overlaps the menu items. Change the position of the Background gameobject to be slightly behind the menu items and OnMouseEnter will register. Also, the line of code that changes the color on the material inside OnMouseEnter doesn't actually change the color of the text...

Can an Android (Java not C/C++) plugin alter unity textures?

java,android,unity3d,android-mediaplayer

It would appears that while i have found nothing explicitly states that this CAN be done, there is no real information or any examples of it having been done before. I'll be attempting a re-working of this in native C++ code....