It looks like you're new here. If you want to get involved, click one of these buttons!
// Convenience utilities written by Malte Hildingsson, malte@hapki.se.
// No copyright is claimed, and you may use it for any purpose you like.
// No warranty for any purpose is expressed or implied.
using System;
using UnityEngine;
using UnityEditor;
namespace Hapki {
public static class EnumExtensions {
public static T[] GetValuesAsInstances<T>(Type etype) {
var names = Enum.GetNames(etype); //aaaa
var array = (T[]) Array.CreateInstance(typeof(T), names.Length);
var assembly = etype.Assembly.FullName;
var space = etype.Namespace;
for (int i = 0, n = names.Length; i < n; ++i) {
var fullName = space != null ? space + "." + names[i] : names[i];
array[i] = (T) Activator.CreateInstance(assembly, fullName).Unwrap();
}
return array;
}
public static T Parse<T>(string name)
where T : struct, IConvertible {
#if NET_4_6
T e;
Enum.TryParse(name, out e);
return e;
#else
try {
return (T) Enum.Parse(typeof(T), name);
} catch {
return default(T);
}
#endif
}
}
public class EnumFlagsAttribute : PropertyAttribute {
}
public class SerializedEnumAttribute : PropertyAttribute {
public readonly Type etype;
public SerializedEnumAttribute(Type etype) {
this.etype = etype;
}
}
}
var fullName = space != null ? space + "." + names[i] : names[i];
Here, 'space' is not a string, but you are trying to use it like one.
Answers
thanks for your help