Quantcast
Channel: Questions in topic: "typecasting"
Browsing all 115 articles
Browse latest View live

JSONObject in JS - random access output converted to string always null?

I am trying to use JSONObject with Unity JS, but I am running into an interesting problem where I cannot convert the values explicitly into strings (for eventually conversion to float in parseFloat)....

View Article



Using an Array of "MyClass" in EditorGUILayout.ObjectField ?

I'm having some trouble with this one! First here's my Monobehavior class that's attached to my GameObject: using UnityEngine; using UnityEditor; using System.Collections; [ExecuteInEditMode] public...

View Article

'time' not a member of 'Object'

I got this from somewhere and I really like it for light trails, but it doesn't play well with #pragma strict. I know in a lot of similar questions that they recommend using List, but I can't use...

View Article

Get name of inherited type?

Hi folks, how can I access the name of a type inherited from MonoBehaviour? I've got a code block that looks like this: var objCollection : List.; for(var obj in objCollection) { Debug.Log("Type: " +...

View Article

Invalid behavior of C# code while using IList on iOS

I have found a strange behavior in my Unity3D project written in C# and built for iPhone. _Sometimes_ IList objects (objects of types which implement IList interface) lose information about elements...

View Article


C# CS0266 error for multiplying by a decimal

I'm not sure why the function below yields this error. It seems to happen because of the *0.5 ... Is it not possible to multiply the sum by a decimal? error CS0266: Cannot implicitly convert type...

View Article

How to perform Explicit typecasting in UnityScript?

Typecasting as in from Object to GameObject, int to float etc.

View Article

Declaring & understanding Class in javascript

Hi Guys, I wish to ask 2 questions about declare class and the concept of it, it also known as typecasting. The code is in javascript (unityscript) From my own understanding, that class in javascript...

View Article


Make compiler treat an object variable as if it was of type X

Hey everyone, I've got a problem here that already had me trying for hours: I have an input which is an object variable (For certain environmental reasons it really cannot be anything but an object),...

View Article


Please Help! :) Loading assetBundle Animations 4.0.0 -> 4.0.1 broke my scene

This Code was working before in 4.0.0.. loading asset bundles via www. I updated from 4.0.0 -> 4.0.1 and my code now gives the following errors in 2 parts of this code.. BCE0019: 'name' is not a...

View Article

How to use methods with the same name from different scripts attached to this...

How do I reference a generic script in another script? So lets say Object AO has script AS with method name "Method()". Another object BO has a script BS with the same name "Method()". Now, I want to...

View Article

How to typecast from a PhotonStream to a variable type in uJS

How do I correctly typecast a value in uJS that is being sent in a stream? While this works, I would like to correctly typecast different variable types from a PhotonStream read (in Unity JavaScript) :...

View Article

Dynamic array length problem.Why my code generate error?

Hi to all. In my project i have some dynamic array of animationclip for holding character animations.my script is such bellow: public AnimationClip[] idleanimations; public AnimationClip[]...

View Article


What is the difference between "as" and (typecast)

Hey guys, I was wondering why I would get an error with the following code (specifically the last line): string[] races = Enum.GetValues(typeof(Race)) as string[]; string randomRace =...

View Article

TypeInferenceRuleAttribute on Resources.LoadAll?

Why does Resources class methods that return arrays of Objects aren't marked with TypeInferenceRuleAttribute as it does for methods that return a single Object (e.g. Resources.Load)? I just want to...

View Article


Classes and subclasses typecasting in unityscript

Hi ! Code first, so i don't get lost into useless specifications: class mydevice { var integrity:float=100; var deviceName:String; } class battery extends mydevice { var storage_power:float } class...

View Article

Classes and subclasses typecasting in unityscript

Hi ! Code first, so i don't get lost into useless specifications: class mydevice { var integrity:float=100; var deviceName:String; } class battery extends mydevice { var storage_power:float } class...

View Article


How do you instantiate a script from a monoscript?

I'm making en editor tool to create prefabs from selected scripts. Selection.objects returns a list of objects which are actually monoscripts. Monoscripts can't seem to be cast as anything, and while I...

View Article

How do I use GetComponent completely correct in this instance?

Okay so, I have a variable called Selector that holds the gameObject.GetComponent("Selector"). Take a look at my code and I'll tell you the issue afterwards. #pragma strict //variables var Selector :...

View Article

Problem with type casting?

The following is my extension method to cast types public static T Cast(this object obj) { return (T)obj; } This is my extension to convert list to array: public static List ToTransformList(this List...

View Article
Browsing all 115 articles
Browse latest View live


Latest Images

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