- Home /
How to create enum out of array of string?
Hi,
I want to create the below scenario :
I have 2 scripts
1 attached to a GameObject with the name "MaterialManager" This accepts the array of strings:
Cobalt, Sandstorm, SangriaRed, Smoke etc This script is constant for one object Should look like this:
I should have one more script with the Name "ProductsEnum" which should have array of enum. This enum should show the MaterialManager's array of string as enum in the editor.
I don't mind keeping an editor button to update the enum list when any new material is added in the material manager.
Can Look something Like this
Can someone please help me do this? All these things must be Custom Editor Script and not the runtime one.
Thanks.
Answer by larex39 · May 07, 2020 at 07:22 AM
Here is youtube tutorial how to show List as Enum in inspector
Your link is broken, here is the fixed one: https://www.youtube.com/watch?v=ThcSHbVh7xc
Answer by Bunny83 · Jan 14, 2018 at 04:28 PM
You can not simply set enum values. Enum values are constant values. Enums need to be compiled while values in an array are runtime values. You can however use an editor script to create a new script file dynamically like shown over here.
Your answer
Follow this Question
Related Questions
Why is my propertydrawer being automatically disabled? 1 Answer
Problem with second enum selection inspector 0 Answers
Custom Editor Access to Scene Objects Variables (in the same way as UnityEvents) 1 Answer
How to create a new SerializedProperty? 0 Answers
Editor.CreateEditor returns null for an object type with a custom editor 1 Answer