Quantcast
Channel: Questions in topic: "typecasting"
Browsing latest articles
Browse All 115 View Live

Why use Resources.Load(string path, Type systemTypeInstance);?

What is the benefit to using Resources.Load(string path, Type systemTypeInstance); over Resources.Load(string path);? They both require a casting. Neither is easier to read (because of the required...

View Article



Custom Editors for any Component

Hey there! I'm searching for a way to create a custom Inspector for any Component; Basically I wish to add a Button under every Component without adressing it specifically in the CustomEditor...

View Article

Can't get method using Generics to populate List

I have the following scenario: public class Human_Behaviour : MonoBehaviour { public static List[,] humanObject; /*... ... STUFF HAPPENS HERE THAT POPULATES humanObject ... ...*/ static List...

View Article

Haxe typedef cast to something meaningful in C#

I have a quite serious headache. A middle-ware library has been developed for my project in Haxe (http://haxe.org/ ). Basically haxe is a meta language, to help cross platform and cross language...

View Article

How to Typecast JS Variables as C# Classes?

If I want to typecast a variable in js as defined in cs. How do I do that? For example: **C# Code** namespace SocketIO { public class SocketIOEvent { public string name { get; set; } public JSONObject...

View Article


Dynamic type, unknown in advance to reuse scripts

I'll like to implement a script that a lot of GameObject will share. The idea is that each gameobject will have then a specific script with their own methods. The idea behind this is to have each...

View Article

Javascript - How to get an error if typing int instead of float?

Basically what I want to do is make sure that if I pass a int into a function that requires a float, I will get an error. So something like this, should give me an error saying it's missing an...

View Article

Identify and Use Unknown Types

I have an object that moves about and must access the script of any object it collides with. Instead of going through and listing every script (Type), I was wondering if there was a way I could detect...

View Article


Native type conversions

I'm working on a Unity native plugin for iOs/Android: I can import the compiled native library, get some basic method to work, but now I cannot seem to find some authoritative document on the details...

View Article


Image may be NSFW.
Clik here to view.

CustomAttribute on Class or Method ( EDIT: Button to call methods)

Hey Guys, EDIT: I think the Headline was a little missleading. I just Wanted simple buttons with method functionality. I was sick to implement custom editors just for simple buttons that is why I tried...

View Article

Custom Class Type Casting (to string)

How can I format a typecasting function in my custom class so that when I pass it off as another parameter type, say string, it uses the function to return an instance of the new type? I'm guessing it...

View Article

gameObject.AddComponent(presetComponent) ?? I would like to add a component...

Lets say we have a Component called "Traits" that has some perimeters. public class Traits : Monobehaviour { public string traitName = "someone"; public float height = 6.2; public float weight = 236;...

View Article

il2cpp type casting issue

Hi there, i need some help i have developed mobile game on unity 4.6.7 when building entire project, i had no problem on unity 4.6.7 (building target is 64bit iOS Machine) by the way, i encountered...

View Article


(int)(variable*float ) problem?

Hi, I am really confused: float deneme = 100f; // or int deneme=100 int a = (int)(deneme * 0.01f); int b = (int)(100 * 0.01f); Why both gives different results? a=0; b=1;

View Article

Why isn't this instantiation cast working?

So i am trying to directly cast a instantiated object as my custom component ClickableTile. TileType tt = tileTypes[tiles[x, y]]; var tile = Instantiate(tt.tileVisualPrefab, new Vector3(x, y, 0),...

View Article


Dynamic casting?

Im not sure if this is even the right question or terms being used. So i have a EditorGUILayout.Popup field that displays all the classes that inherit from a abstract class. Throw those classes names...

View Article

How to TypeCast T(Generic Type) into some Class DataType

Hi, I am little bit confuse in type casting through Generic Type. Here in my below code if my mainClassObject of Type T is a type of SignInEventHandler. I want to typecast T in SignInEventHandler type...

View Article


Best way use Resources.Load for spcific type?

There are 3 ways using Resources.Load: 1. `Resources.Load ("objectPath");` 2. `Resources.Load ("objectPath", typeof (GameObject));` 3. `Resources.Load ("objectPath") as GameObject;` Are they all the...

View Article

Typecasting problem?

Hello! I have GameObject named "EyeLight". I've buried "EyeLight" deep in heiarchy of Game objects. How can I reach it to enable / disable? Everything I've tried so far has been bunk - Light...

View Article

Dynamic Type Casting

I could use some help on this one. Is it possible to dynamically type cast something? Here is what I am doing: GameObject holder; holder = (string.IsNullOrEmpty(action.tagOfHolder) == false) ?...

View Article

Sprite Rendering

(I'm using Unity 5.5) Hi everyone, I am writing a mobile game that uses many different icons at any given time, so I'm loading all my images at runtime to reduce size and compilation time loading. I...

View Article


Instance of JsonData Doesn't hold an int even though im typcasting..

Hey guys so i'm writing an inventory script passing data using JSON. I started following a guide online however I am casting the same way as him yet I am getting an error. Here is my script I'm using...

View Article


How can I use a variable with getcomponent()?

I want to use a variable to call functions from a script. Here's an example of pseudo-code: //myString is the name of an existing script. someOperation is what I need help with....

View Article

A smarter Way to get the Type of SerializedProperty

Hey Folks. I used the DrawDefaultInspectorWithoutScriptField by [JAKJ][1] and it gave me kind of the Idea of creating a custom Inspector, that could inject content where I want without writing...

View Article

How do I give an object a script component of a type specified by the calling...

public static void Init(GameObject target, bool preserveOriginal, string classTemplateToAssign) { MonoBehaviour[] mb = target.GetComponents().ToArray(); if (mb.Length != 0) { //PooledObject po =...

View Article


I get byte[] from unitywebrequest.get . now how can i change byte[] to...

typeconversion is a real mess.it always giving me error that byte[] cannot be converted into assetbundle or other type.(there are few exceptions like texture as they have methods to convert from byte[]...

View Article

Adding type convertions to unity core types

I wanted to add an conversion between one of my custom types `Block` and a unity core type `Vector2Int` so that i could write `Block John = (Block)vector2Int;` where do i need to put my existent...

View Article

Unity. Some fields go to null on Play

I Mean those fields. [SerializeField] public Type gameStateType; [SerializeField] public IGameStateParams gameStateParams; I made in Editor methods to set those fields up, but, when click **Play** they...

View Article

How to find and access a TextField child

I have a button that has two transform fields (addr, port) referenced to two TextField components. I want to set the text values. However, when I try to convert them to TextField, and error occurred:...

View Article



To call inherited functions of a common parent from different types of...

Hello First of all, thank you for reading this article. Also, thank you again for solving this problem in advance :) Here's an example of my problem and my intentions. Example: public abstract class...

View Article
Browsing latest articles
Browse All 115 View Live




Latest Images