Quantcast
Channel: Questions in topic: "declare"
Browsing latest articles
Browse All 78 View Live
↧

Redim a variable

How can I change the type of a variable in unity-js? I didn't find anything about it on the forums. If there is no way: Is it possible to "kill" a variable so I can re-declare it afterwards? I want to...

View Article


name of script to declare

i want to declare a script but my script's name goes like this... "script rotate" var script : script rotate; but it returns the error: UCE0001: ';' expected. Insert a semicolon at the end.

View Article


C# - Appropriate place for constants, variables, declarations, and...

Hi guys. I'm new to Unity. Would anyone mind telling me the appropriate place for declaring and initializing constants and variables? For example, below is a script I wrote that animates a gun. At the...

View Article

How to declare a struct in C#

Hello everyone. I'm trying to create a simple struct to hold data (not methods, just some properties), and I want it to be accessible from all my other scripts, like if it was just another class from...

View Article

Declaring a Vector3 variable in C#

Can a Vector3 be a variable? I thought so, but I can't seem to find the correct syntax. How do I make this work? for (float i = 0 ; i < blockX; i++) { Vector3 rowX = (i,0,0); //error on this line...

View Article


Very simple question

I have made quite a few JS scripts in Unity, like car and AI car scripts, but I have always dodged this problem. I declare a public var 'firstVar' in one script, and attach it to a gameobject...

View Article

why declare boolean value before functions didnt work?

Hi Guys, The clockIsPaused (boolean type) only returns true if I declare it in the function. But why at the top or before the function, it didn't work? I thought we can input all the values when we...

View Article

why function datatype i.e. function foo() : int {

I just found an answer on the forum where the guy defines the data type for a function, and returns a value at the end of the function,it goes like this: function MaxValue (intArray : int[]) : int {...

View Article


How can I declare a variable as the 100% of another variable?

How can I declare a variable as the 100% of another variable? Example: var amount : int = 30; var percent : int = 100; Percent variable must be the same as the amount variable. Example: percent =...

View Article


Can eval() declare functions (such as Update())

When i tried to make eval declare the Update function (like this:) function Start() { eval("function OnGUI(){ GUI.Box(Rect(310,20,300,50),"Test 123".ToString()); }"); } it said nothing, but it didn't...

View Article

C# if If Statement is True Declare Variable

Hi everyone, how do declare a variable inside of an if statement? I want to declare a variable when a specific if statement is true. But I'm not sure how.

View Article

How should I declare a nested class to find it latter with...

Hello. I'm trying to imitate what was explained on the [Unite 11 Intro to Editor Scripting][1] on a ScriptableObject class. The class contain an array of another "class of the class". Example : public...

View Article

How declare values in C#

function Start() { // Store a bunch of different positions in an Array: var aPositions : Array = [new Vector3(0,0,0), new Vector3(1,2,1), new Vector3(2,1,1), new Vector3(2,0,0), new Vector3(0,3,0)];...

View Article


C#: Declaring a script as a variable

public class WallProperties : MonoBehaviour { public Door door; public bool IsDoor(bool enable) //enable=true { if(enable) { print (enable); //prints true door=new Door(); door.DoorStart(); //sets...

View Article

Can't use declared variable to find nearest Object

Hello everybody, I want to "respawn" a player to the race track when he falls off the map and touches a trigger volume, this is my code : GameObject GetClosestObject(string tag) { GameObject...

View Article


Why do these variables work without declaring type? (JS)

I have a script here that I'm using for a little game I'm making where the player squishes mosquitos. This script is designed to destroy a prefab and replace it with a pair of new prefabs, and I made...

View Article

2-dimensional array in JS

Could anyone help me with 2d arrays? Because I would like to store my item info loaded from an online database in a 2d array like: //Item with ID #0 item[0,0] = "Chain Helmet"; //Name item[0,1] = 10;...

View Article


convert variables to C#?

var audio1 : AudioSource; var audio2 : AudioSource; i see javascript examples all the time im just not sure how to declare these variables in c# i know its dumb.

View Article

C# Custom Class - Declare Variable's Value

Ok, I made a custom Item class that does not inherit from MonoBehavior: using UnityEngine; using System.Collections; [System.Serializable] public class Item { public string id; public string...

View Article

How do i declare a negative float while initializing a vector?

This should be basic, baby stuff. Here's a little snippet of my code: public Vector2 SubjectScreenOffset = new Vector2(-0.125f, 0.0f);//offset from the centre of the screen. a value of +-0.5 will reach...

View Article

declare script as variable, with variable in it type

hello there :) in this project players can generate script, and then save it with any name they want. in Dropdown players can choose they script's name and attach it to gameObject. all is fine except...

View Article


Is there a cleaner way to set all the properties when declaring a new object?

Here's a script I'm writing: void generateLevel(){ MatchManager.levelInfo generatedLevel; generatedLevel.baseWidth = 5; generatedLevel.tableWidth = 32; generatedLevel.tableHeight = 20;...

View Article


Error Initialize array two dimensions C#

First Class: using UnityEngine; using System.Collections; public class Slot : MonoBehaviour { public string State= "VACIO"; public string Player; } Second Class: using UnityEngine; using...

View Article

A field initializer cannot reference the nonstatic field, method, or property

Hi, I searched on the internet about this problem but the answers didn't help, so I'd like to ask you how to avoid this error. (I'm a beginner so please don't lynch me if it's a stupid question xD)....

View Article

why do i get the error Object reference not set to an instance of an object?

when i click play i get this error NullReferenceException: Object reference not set to an instance of an object GravityScript.Update () (at Assets/Scripts/GravityScript.cs:22) i am trying to get the...

View Article


How to define arrays in shaders?

I'm new to using shaders, and i can't figure out how to define an array in shaders. I just want to define an array of floats or halfs. I managed to DECLARE one, but that's as far as i got. I could...

View Article
Browsing latest articles
Browse All 78 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>