Category: Unity
-
Using a bigger Range of colours from code in Unity
Create a new C# script in your project called CSSColors.cs and then copy and paste the code below into it. You should then be able to use the colour names specified anywhere in your project. public class CSSColors { // NOTE: The follwing color names come from the CSS3 specification, // Section 4.3 Extended…
-
Automatic Android Code Signing in Unity
Create a new folder in your project called Editor Within that folder create a new C# script called something like PreloadSigningAlias.cs Copy and paste the code below into the script and save it. Replace KEYSTORE_PASS with the password to your keystore Replace ALIAS_NAME with the name of your android alias Replace ALIAS_PASSWORD with the password…
-
How to solve the “type or namespace UnityEngine.UI does not exist” in Unity
How to solve the “type or namespace UnityEngine.UI does not exist” in Unity From the Asset menu choose Reimport All That worked for me.
-
Playing A Sound in Unity
Here’s a simple way to play a sound in Unity. 1. Add something like this to the declaration section of your script. public AudioSource audioSourceExplosion; 2. Add this line of code where you want to play the sound. audioSourceExplosion.Play(); 3. NOTE : What I have called audioSourceExplosion here is the name of the variable and of…
-
Changing C# template for Unity
The template files for Unity’s scripts are kept in Program FilesUnityEditorDataResourcesScriptTemplates The new behaviour script, the most common one is called (or something similar, depending on version) 81-C# Script-NewBehaviourScript.cs.txt
-
Getting a button to change a text object in Unity 3D
Using a button to change the text of a text object 1. Insert a Text object using Create -> UI -> Text 2. Insert a Button, using Create -> UI -> Button 3. Create a new script, using Create -> C# Script 4. At the top of the script, add another using statement, using UnityEngine.UI; at the…