Quantcast
Channel: Questions in topic: "class instance"
Browsing all 131 articles
Browse latest View live
↧

How to search a certain variable in a list of a created class (C#)

Wasn't to sure how to word the question so here's a description with code below. I have a list which takes type of Room (a class i created) and this class has a contructor to create many instances of...

View Article


How would I handle having one instance of 2 possible class, one derived from...

I know that may sound odd, so let me elaborate. I am creating a custom character controller, but with 2 separate versions, a basic type & an advanced type, advanced inheriting from the basic. They...

View Article


c# class array not showing up in inspector

This might seem like a stupid question, but I can't figure out why it doesn't work. I have a c# class not inheriting from MonoBehaviour and marked as serializable. Then I have another (normal...

View Article

How to create a repository of enemy objects that are initialised but then get...

I am attempting to create a really simple turn based rpg. I have created an enemy object as follows: public class Enemy() { int attack; int hp; string name; public Enemy(string _name, int _hp, int...

View Article

create custom class

HI. I want create custom class in my script and define custom variables in this class. for do this I create another public class and defined my variables inside it. but when i play the game, it give me...

View Article


How to apply script saved in variable

Hi to all. I want to add a component saved to a variable from "heal heart" to a character, who will collide with it. I dont want to use col.gameObject.AddComponent (); Because there will be several...

View Article

Naming an Instance of a class

Good afternoon, I'm having trouble figuring out how to name an instance of a class automatically. What i mean in detail is i am trying to create a recipe book that a user can put in a name, ingredients...

View Article

Serialize Variables from Items in an Array

Hello, I have created a base class with a few variables able to be assigned from it. In another script, I have created an array of this class. Would it be possible to create these classes here, in the...

View Article


Does attaching a derived class script to a gameobject create a new instance...

So I have a base abstract class called CurrentAnimation and two simple derived classes that inherit from it. Each derived class is attached as a script to a gameobject (FadeOutCtrl to a Fadeout...

View Article


Control which class is instantiated first

In the scenario where I have two classes, `AClass` and `BClass`, which both have some basic code in the constructor, but AClass relies on BClass being instantiated first , how can I control the order...

View Article

Way to copy a Class without copying the references?

I am trying to make a game of evolving simply creatures for a simple project. When each object is done simulating I take the fittest one and display it. I would like to make a copy of the initial...

View Article

I'm struggling with assigning unique attributes to prefab objects.

As a test for a much larger project, I'm creating five primitive cubes (prefabs) and want to assign each a unique "Name" and two unique numbers assigned at random...I plan to access and manipulate...

View Article

Loading class instances from Json file gives ArgumentNullException

In my game, I have a Computer class with following variables: [System.Serializable] public class Computer : MonoBehaviour, ShopItem{ public string model; public int price; public int speed; public int...

View Article


C# Inheritance and passing Components

Hi !, Been learning inheritance and passing variables and parameters between classes and subclasses. Also tried to setup sphere collider from base class by passing neccesary variables from derived...

View Article

Merging multiple array's from a specific class without manually targeting them

Hello, I got into Unity really hardcore, around 8-12 hours a day of continues learning, I just can't stop. _ the problem is that I'm trying to merge multiple arrays into one. _ I know about...

View Article


How to correctly use MonoBehaviour inherited class?

Hi, I'm trying to use a class structure to store coroutines responsible for spawning enemy waves. I already regret the idea but want to get to the bottom of it. My **Spawn_Manger** script is attached...

View Article

singleton pointer and updating variables of the singleton with the pointer

When i have created a player class and created a singleton in it: public static Player instance; void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of Inventory found");...

View Article


Error referencing custom class elements

Hello everyone. I've been working in a grid based project in which I save an instance of the class "Cell" in a "grid[ , ]" array, that represents each particular cell of the grid and conteins...

View Article

In the second script "InputManger" should be glowing but it is not. Why is...

using System.Collections; using System.Collections.Generic; using UnityEngine; public class InputManager : MonoBehaviour { // Start is called before the first frame update public float throttle; public...

View Article

is class variable in a ScriptableObject automaticly Instantiated?

while I created an Instance of ScriptableObject with a class variable in it, in the inspector it shows the class variable as default instance of the class, do I still need to add a null checker before...

View Article
Browsing all 131 articles
Browse latest View live


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