Tag Info

New answers tagged

0

In the past, I've attached a script to the music AudioSource that sets ignoreListenerVolume, to bypass the main volume controls. A crude example to get the point across: void Start() { AudioSource music = GetComponent<AudioSource>(); music.ignoreListenerVolume = true; //you can manage the music's volume directly, now music.volume *= ...


1

I looked at the source code, and it looks like InstantiateAPS requires the Prefab name as a parameter. poolingSystem.InstantiateAPS("Skeleton"); This should probably work, so as long as you actually have a Skeleton prefab in your Resources folder.


2

The default sprite size in Unity is 100 pixels per unit. This means that if you have a sprite that is 100 pixels wide, it would occupy "1" Unity unit. If you moved this sprite to the left by 1 unit, it would shift 100 pixels to the left. You can change this value by selecting your sprite, and changing its "Pixels per Unit" property. I typically set my ...


0

I asked this question when i was an absolute newcomer. Answering this now so someone looking for this finds the solution. First part of my question was about setting camera size so a certain background fits the screen perfectly, both horizontally and vertically. Now, I know that's a bad idea. Because, having a background fit one single size means skybox will ...


1

On Windows: %APPDATA%/Unity/Editor-n.x/Preferences/Layouts On OSX: ~/Library/Preferences/Unity/Editor-n.x/Layouts Where n is the major version number of the Unity Editor in question, %APPDATA% is your AppData/Roaming hidden folder in your user folder (on Windows) and ~ is your home directory (on Mac).


1

http://answers.unity3d.com/questions/16603/is-there-a-global-volume-setting.html Use the slider's value to determine the AudioListener.volume static field. http://docs.unity3d.com/ScriptReference/AudioListener-volume.html It is between 0 and 1. You can get a normalised( between 0 and 1 ) value from the slider using Slider.normalizedValue.


0

using UnityEngine; using UnityEngine.UI; public class SliderSaver : MonoBehaviour { public Slider slider; void Awake () { slider.Value = PlayerPrefs.GetFloat ("Slider value"); } public void OnSliderChange (float newValue) { PlayerPrefs.SetFloat ("Slider value", newValue); } } This sets the slider's value in ...


0

That one is easy and, yes, even after many years as a programmer I stumble upon this kind of situation. In SpriteChange you change values held by your levelManager: levelManager.highlight = "none"; levelManager.highlightDirection = "none"; levelManager.changelight = "none"; levelManager.changelightDirection = "none"; However, in your else parts of your ...


0

GetComponent<AudioSource>().volume=hSliderValue; This line is C#, not Javascript, or UnityScript.


1

You can see Editor build log to check which files contribute most to the size of your build. You can open it from within Unity by clicking on the list icon right abot the error icon on console view. (See image attached) Then you can see if you have unecessary assets and reduce size of others. You can also strip assemblies in the final build to reduce ...


0

One approach is to set ignoreListenerPause on the AudioSource for your music and then set a mute on the overall game using AudioListener.pause. Now AudioListener.pause will mute everything except your music, while you can still mute that audio source directly. I take that approach in the audio chapter of my book (see my profile).


1

This is not directly possible in Unity because: There is no difference between sound and music for the Audio Sources The volume of every Audio Source is independent of eachother You will need to search for the Audio Sources in your local scene to iterate through them with Object.FindObjectsOfType. var audioSources = ...


0

One thing to think about here is that you are updating the entire mesh UV state for each tile you modify. I'd be sure to check and make sure it's not refreshing the mesh after each tile. you might return the UV updated array one level up and marge them all at once. Basically restructure so you calculate all, then apply the changes to the chunk/mesh. I also ...


1

What you want to do is program the chef to move toward its target destination; every frame in Update() check if the chef is at the target, and if not move a bit toward the target. Then clicking on a pot sets the target position. Something like this pseudo-code: Chef { Vector3 target; Update() { if (chef.position != target) { ...


1

One thing I would be careful about is using the correct input callback. I would suggest one of two things, read the API's on the input methods available, and choose the one appropriate to your desired behavior. Some callbacks only fire if the key is held down, and others fire on a tap. Secondly, your architecture should change a little bit. The callback ...


2

I don't think . But you can try to call a javacript like this (using Application.ExternalEval(.. ): <script type="text/javascript" language="javascript"> <!-- //initializing the WebPlayer var u = new UnityObject2(); u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d"); function SaySomethingToUnity() { u.getUnity().SendMessage("MyObject", ...


0

As Ben's suggestion, help me to found an answer. Mark [ExecuteInEditMode] on top of the Monobehavior class that I need to assign var to. Use AssetDatabase.LoadAssetAtPath to load the resource I need into variable type that I want. Save scene. Remove script that add recently if you don't need it in production.


0

The problem is here: it looks like you directly dropped the script instead of the object to which it is attached. Let's say your "Restart" script is attached to MainCamera. You need to assign Main Camera in the field marked red.Then select a script attached to main Camera, which is Restart, from that select a method which is ReStartGame(). When you do ...


1

I followed @nexx's comment. and made a 2 pass surface shader which give colors to hidden pixels. You can use built-in light function or Unlit version(commented). Hope this help for others finding this kinds of effects. Shader "Test/HiddenPixelColoring" { Properties { _MainTex ("Texture", 2D) = "white" { } } SubShader { ...


1

A ready to use method which is better than SystemInfo.operatingSystem : public int GetSDKLevel() { var clazz = AndroidJNI.FindClass("android.os.Build$VERSION"); var fieldID = AndroidJNI.GetStaticFieldID(clazz, "SDK_INT", "I"); var sdkLevel = AndroidJNI.GetStaticIntField(clazz, fieldID); return sdkLevel; } Just copy and paste and that's ...


0

Put the Debug.Log before the Loadlevel instruction. What happens now is, LoadLevel is executed and everything is destroyed, including the button which was clicked. When new scene is loaded, everything in current scene is automatically destroyed. If you want an object to be present across multiple scenes, check the manual for DontDestroyOnLoad().


0

What you are describing is not occlusion. Your objects in the image are rendered but are overwritten by the other object because of a higher Z depth. What you are trying to achieve could be done using a shader that nexx mentioned earlier. For example this one could help you: http://forum.unity3d.com/threads/trying-to-make-a-silhouette-outline-shader.96005 ...


0

I believe your problem here is that you are clearing out your list in OnBeforeSerialize() and recreating it in onAfterDeserialized(). I think your problem is that you are expecting OnAfterDeserialized() to be called after OnBeforeSerialize() and after you have added a new item to your list in the custom inspector (a reasonable assumption). However this does ...


0

Many infinite runners scroll the world instead of the player to prevent the problem of float overflow. Also, this makes several things easier to manage like player movement and the camera. For scrolling backgrounds, you can use parallax scrolling. Basically, farther objects appear to move less relative to closer objects across the same distance. For ...


0

Try to change the tris for loop to ++ instead of +=3: for(int i = 0; i < m.vertices.Length-3; i++){ tris.Add(i+2); tris.Add(i+1); tris.Add(i); } Each 2 neighboring triangles have 2 shared vertices, so += 3 would skip 2 triangles each time.


0

I have a basic solution for Step 2, but it's not reversible for Step 3. Simply make a isometric camera and make the display at the bottom of the view Creating an Isometric Camera in Unity 2 cameras renderring at the same time Another method (my imagination) is make the Line Drawing to "modify" the material of the mesh, and then use the same material on ...


0

It seems your scene(s) has/have corrupted, the system can't read some particular scene(s). Try to check every scene to find out which one has corrupted, if you do have a backup then restore the scene files. Unity Manual: Textual Scene File Format - Format Description


3

If you don't specify an f at the end of a decimal value in C#, it's assumed to be of type double. To preserve precision, double does not implicitly cast to float. So because of the .5 you put in the y (rather than the -9.5f in the tutorial's code), your examples have the signatures: new Vector3(int, double, int) new Vector3(int, double, float) ...both of ...


1

If I understand correctly, what you want to compute is the spline's radius of curvature at each point. Then you want to compare that value to an agent's turning radius to determine if the agent will leave the track there. [1] To do this, you need to calculateR(s)as you see here: https://en.wikipedia.org/wiki/Curvature (under "Curvature of plane curves" > ...


0

In Player settings → Optimizations → SDK, I had to select simulator SDK, instead of device SDK. That resolves this.


1

You don't need the pro license to release games for any platform. You just have to upgrade if you made more than 100k in funding or revenue. I believe paid advertisements can be done with the free version. https://unity3d.com/unity/faq


0

Properties like transform or gameObject are shortcuts for GetComponent<Transform>(). So yes, the GameObject your script is attached to is the Object the script "sees". To your second question im not sure what you mean with manipulate but most of the time the answer is yes. MonoBehaviours should (mostly) only affect the GameObjects they're attached to. ...


1

Yes, you are stuck with needing a child object for each individual sprite that makes up your characters. It's not as tricky as it sounds though. You can create one generic "Humanoid Character" prefab with child objects like "Body", "Helmet", "Weapon", etc. You can then use this prefab for both PC and NPCs. Layers Pay attention to Sprites layering. Almost ...


-1

If you create a single material for the sprites, and they use a spritesheet, they should be batched into a single draw call automatically. :) From the Unity3D answer hub (kindly answered by ivomarel): Yes, make sure that the sprites are in the same atlas. When you select a sprite, (Texture type should be sprite), look at the inspector and choose ...


2

This bit: void Update() { StartCoroutine (TurretWaves()); } Once you start a coroutine, it will continue processing automatically. If you call StartCoroutine twice, you will launch two independent coroutines. If you call StartCoroutine once per frame, you will start a new, fully independent coroutine on every frame. By the time your game finishes ...


0

Usualy it's a good practise to use StartCoroutine into the Start(), you're "starting" a coroutine on every update!! Here can find some examples on using StartCoroutine. using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Start() { print("Starting " + Time.time); ...


0

The asset bundle system does not automatically remove anything nor does it load dependencies automatically. Dependencies are included in asset bundles automatically, but actually exist in each asset bundle that depends on them, unless you manually removed them. For example, if you have a 2 different player models, Hero1 and Hero2. They both share a Gun ...


0

The asset bundle dependencies are not processed in the "load", but when the asset bundle is created. Unity basically loads the entire asset bundle in at at a time, and then instantiates particular assets inside the asset bundle. To remove asset bundle dependencies at build time, take a look at the AssetBundle.PushAssetDependencies function. Any assets that ...


0

Without knowing more about your code, its difficult to say why it would be running that slow. I can't imagine it taking 1-2 seconds to update 32000 UVs, that's not that large of a number, so my guess is that its doing something else horrible because of the fact that you are updating that many UVs. Either way, your solution will be similar. Since all the ...


2

Here are some answers to your questions: 1) If you want your sprite sheet to be compressed (which will reduce memory usage, at the cost of some quality), you will want it to be a power of two. If you are going to do completely uncompressed textures, then any size is OK. My recommendation is to stick with the power of 2, since that gives you the flexibility ...


-1

3D objects still have an X and Z coordinate. The only thing you have to do to make it isometric in 3D settings is to ensure the Y value for all the tile objects are the same. Generally we set this to 0. Put your camera wherever you like the angle, and voila! I hope this clears things up.


0

There's a trick to this: Selecting Areas: As you move the mouse, the only tiles you need to check for new impassable tiles are the newly highlighted tiles. If the mouse is dragged from X=25 to X=26, then you only need to iterate over the tiles at the X=26 column from the Y of the starting tile to the Y of the tile the mouse is over. The worst case scenario ...


0

From your example I can tell you're making a "connect the pipes" type game. You have two possible approaches here: You can hard code each level, testing the map array for a specific total state, making sure that A2, A3, and A4 are all orange. You can program a pathing algorithm to test if there is a path between the two colors. The second option will be ...


1

It is possible though inconvenient. You'd have to write managed C++ to achieve it. And yes, there is such thing as managed C++. Managed doesn't specifically mean C# and unmanaged C++. To achieve it you'll need to import UnityEngine DLL file. When you're finished you put it in the (Unity Project Name)/Plugins folder. Here would be the code you'd use: In the ...


1

Here is an official tutorial by Unity http://m.youtube.com/watch?v=C3izqF6h_aY


0

By using raycast, you can accept touch gesture per layer (see unity Raycast documentation). I think it's better to put panning object and your sprite on different layer. Then you may check for raycast colliding with your panning object and sprite. I think it's better to use different touch gesture, like tap for interacting with sprite and sliding fingers ...


1

DMGregory posted this and I'm just copying his comment to be able to close this question with an answer. You're rotating with respect to Space.World. So if your camera's z-axis is pointing along the world x-axis, then what you're applying as a pitch (world x-axist rotation) will be observed as a roll (local z-axis rotation). Does the problem ...


0

After playing around with things, I've decided to use Blender's stencil map feature (which is a reduced sort of splat map). It allows me to blend between two tileable textures on the same surface using a third as a stencil without having to use huge textures. I also had to write a custom shader in unity to have my stencil material display, but that wasn't ...


0

You need to work with the basic Transform methods. At first you need the target position to know from where to start the calculation. Then you substract the direction vector to receive a new position for the camera. To set the camera view to the target transform use transform.LookAt. public Transform targetTransform; public float distanceToTarget; void ...


2

The default sprite filter mode in Unity is set to Bilinear. If you change it to Point, it will retain the pixel crisp. http://docs.unity3d.com/ScriptReference/FilterMode.html



Top 50 recent answers are included