- Home /
Question by
NutellaDaddy · Mar 30, 2014 at 06:12 PM ·
c#variablesstaticaccessing
How can I edit my static variable in the editor?
If I can't apply my static variable in the editor than is there any other way to apply the texture2d fro my icon while its static? Here's the script: using UnityEngine; using System.Collections;
public class AllItems : MonoBehaviour
{
//ICONS
static public Texture2D macheteIcon;
public static void ItemsAndStats()
{
/////////////////////////////////
//WEAPONS
//GUNS
Weapon machete = new Weapon (10.0f, 0.0f, 3, false, 0, false);
machete.name = "Machete";
machete.description = "A fast bladed weapon";
machete.icon = macheteIcon;
machete.rarity = RarityType.Common;
machete.curDurability = 150.0f;
machete.maxDurability = 150.0f;
machete.weightAmount = 1;
//MELEE
//LASER
//BASIC RANGED
/////////////////////////////////
//CONSUMABLES
//FOOD
//LIQUID
//HEALTH
/////////////////////////////////
//ARMOR
//BASIC
//ADVANCED
/////////////////////////////////
//BUILDINGS
/////////////////////////////////
//STATIONS
//CRAFTING
//COOKING
//OTHER
/////////////////////////////////
//CONTAINERS
//BASIC
//LOCKED OR LARGE
}
}
Comment
Best Answer
Answer by raycosantana · Mar 30, 2014 at 06:37 PM
No sorry, static variables can not be edited in the editor. Maybe you could add another non-static public variable and assign this variable to macheteIcon
public Texture2D MacheteIconTemp;
static public Texture2D macheteIcon;
void Start(){
macheteIcon = MacheteIconTemp;
}
In this case you also need to make sure that you only have this component only once in your scene.
If you got this one on two objects and assign different values, the last one will become the static.