Trying to make something happen in the Editor and not runtime, how do you do this/is it possible?
I want to make a script that I attach to gameobjects in a scene. I want the these objects to have one or more attributes. What I am trying to do is when I attach the script to the gameobject it will have checkboxes for various attributes, like if it is a food item you will check that box, if it is water or health you check one of those boxes. The problem comes because I want the script to, if you check one of those attributes, create or expose a variable to tell it how much to give of whatever the attribute is. For example, if I check that health it true, I want a new window to appear with a float variable where I can enter the amount of health for that object. I want to do this to make it fast and easy to make and change a large number of these through the editor without having to go into the code to do it. Here is the script idea-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Attributes : MonoBehaviour
{
public static float health; //this will go in my main health script, not here
public bool isHealth;
/* if (isHealth == true) // I want to create a new public variable newHealth in the editor, not at runtime
{
public float newHealth;
}*/
public bool isWater;
public bool isFood;
public bool isCraftable;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Consume()
{
health = health + newHealth; //his is the second big problem. if I use a variable before it is
created, it will throw an error of course, any way around that? } }
Your answer
Follow this Question
Related Questions
Disable the selection box in the editor scene 2 Answers
Scene editor clips through everything when too close? 0 Answers
Custom EditorWindow indicator 0 Answers
UIElements - Horizontal scrolling is not working in ScrollView even with ScrollViewMode.Horizontal. 0 Answers
Tracking changes of a Component on the selected GameObject in custom EditorWindow 1 Answer