public virtual void Init(object obj, Type valueType) { if (valueType == null && obj == null) { return; } InteractiveValue interactive; if (valueType == typeof(GameObject) || valueType == typeof(Transform)) { interactive = new InteractiveGameObject(); } else if (valueType.IsPrimitive || valueType == typeof(string)) { interactive = new InteractivePrimitive(); } else if (valueType.IsEnum) { if (valueType.GetCustomAttributes(typeof(FlagsAttribute), true) is object[] attributes && attributes.Length > 0) { interactive = new InteractiveFlags(); } else { interactive = new InteractiveEnum(); } }
void OnEnable() { t = ((InteractivePrimitive)target); if (!t.sizing) { return; } t.GetComponent <Renderer>().enabled = false; dragState = DragState.None; Tools.current = Tool.Move; }
public virtual void Init(object obj, Type valueType) { if (valueType == null && obj == null) { return; } //ExplorerCore.Log("Initializing InteractiveValue of type " + valueType.FullName); InteractiveValue interactive; if (valueType == typeof(GameObject) || valueType == typeof(Transform)) { interactive = new InteractiveGameObject(); } else if (valueType == typeof(Texture2D)) { interactive = new InteractiveTexture2D(); } else if (valueType == typeof(Texture)) { interactive = new InteractiveTexture(); } else if (valueType == typeof(Sprite)) { interactive = new InteractiveSprite(); } else if (valueType.IsPrimitive || valueType == typeof(string)) { interactive = new InteractivePrimitive(); } else if (valueType.IsEnum) { if (valueType.GetCustomAttributes(typeof(FlagsAttribute), true) is object[] attributes && attributes.Length > 0) { interactive = new InteractiveFlags(); } else { interactive = new InteractiveEnum(); } }
public override void OnInspectorGUI() { InteractivePrimitive primitive = ((InteractivePrimitive)target); if (primitive.hasSubdivisions) { EditorGUI.BeginChangeCheck(); int subs = primitive.GetSubdivisions(); subs = EditorGUILayout.IntField("Subdivisions", subs); if (EditorGUI.EndChangeCheck()) { primitive.SetSubdivisions((int)Mathf.Clamp(subs, primitive.MinSubdivisions, primitive.MaxSubdivisions)); primitive.SetMeshDimensions(primitive.baseStart, primitive.baseEnd, primitive.height); primitive.ToMesh(); primitive.OnFinishDragSizing(); } } }