using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
{
public class NonSerializedExamples
{
static List<Type> listOfTypes = new List<Type>() { typeof(TextMesh), typeof(string), typeof(MonoBehaviour) };
static List<Vector3> listOfVectors = new List<Vector3>();
static UnityEngine.Object objectReference = null;
static bool numberLists = true;
public static void DrawPrefs()
{
if (GUILayout.Button("reset"))
{
listOfTypes.Clear();
listOfVectors.Clear();
objectReference = null;
}
EditorGUILayout.LabelField("Example of displaying Lists that are NOT serialized, in an editor. (Recompiling, or reloading the scene or project will reset these values.)");
numberLists = EditorGUILayout.Toggle("Number Lists", numberLists);
listOfTypes = EditorUtil.SimpleListFieldLayout<Type>(new GUIContent("List of Components"), listOfTypes, PopupComponentTypes,default(Type), numberLists);
listOfVectors = EditorUtil.SimpleListFieldLayout<Vector3>(new GUIContent("List of Vector3s"), listOfVectors,null,Vector3.zero, numberLists);
objectReference = EditorGUILayout.ObjectField("Object Reference",objectReference, typeof(ScriptableObject),false);
bool renameNow = EditorGUILayout.Toggle("Rename Object", false);
if (renameNow)
{
System.Action<string> renameCallback = new System.Action<string>(
(xstr) =>
{
objectReference.name = xstr;
SettingsService.NotifySettingsProviderChanged();
});
RenamePopupWindow.PopUp(objectReference.name, renameCallback, false, "Rename Object",default(Rect), objectReference);
}
}
static public object PopupComponentTypes(GUIContent label,object objectToDraw)
{
List<System.Type> ignored;
Type selecteType=EditorUtil.TypePopup(label, (System.Type)objectToDraw, typeof(Component), out ignored, true);
return (object)selecteType;
}
}
}