- Home /
Pair Switch Cases to individual elements in a Vector3 array?
I have an array of Vector3s and a switch with two cases, Move, and Rotate. While I can set move or rotate globally for the script what I would like to be able to do is set each individual Vector 3 element in the Vector3 array to use either Move or Rotate. Is this possible? I understand it may involve a custom property drawer or editor script to create a custom GUI to do this, but I am wondering how to store or assign a case selection to be paired with an element in the Vector3 array?
Answer by casimps1 · Feb 25, 2014 at 03:17 PM
public enum ActionType {
Move,
Rotate
}
[System.Serializable]
public class VectorAction {
Vector3 vect;
ActionType action;
}
Then, just make an array of VectorActions instead of Vector3s. The System.Serializable attribute is what will magically make it expand out the VectorAction class into its properties in the Inspector. If you won't be setting these up in the Inspector you can leave off the Serializable attribute.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Array empties values on RunTime? 1 Answer
For loop not running correctly inside start () 1 Answer
instantiate problem help? 1 Answer
Add a copy of a object to Array 1 Answer