GetDefaultReference() private method

private GetDefaultReference ( string name ) : Object
name string
return Object
示例#1
0
 private void ShowFieldInfo(System.Type type, MonoImporter importer, List <string> names, List <UnityEngine.Object> objects, ref bool didModify)
 {
     if (IsTypeCompatible(type))
     {
         this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
         foreach (System.Reflection.FieldInfo info in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
         {
             if (!info.IsPublic)
             {
                 object[] customAttributes = info.GetCustomAttributes(typeof(SerializeField), true);
                 if ((customAttributes == null) || (customAttributes.Length == 0))
                 {
                     continue;
                 }
             }
             if (info.FieldType.IsSubclassOf(typeof(UnityEngine.Object)) || (info.FieldType == typeof(UnityEngine.Object)))
             {
                 UnityEngine.Object defaultReference = importer.GetDefaultReference(info.Name);
                 UnityEngine.Object item             = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(info.Name), defaultReference, info.FieldType, false, new GUILayoutOption[0]);
                 names.Add(info.Name);
                 objects.Add(item);
                 if (defaultReference != item)
                 {
                     didModify = true;
                 }
             }
         }
     }
 }
示例#2
0
        void ShowFieldInfo(Type type, MonoImporter importer, List<string> names, List<Object> objects, ref bool didModify)
        {
            // Only show default properties for types that support it (so far only MonoBehaviour derived types)
            if (!IsTypeCompatible(type))
                return;

            ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);

            FieldInfo[] infos = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
            foreach (FieldInfo field in infos)
            {
                if (!field.IsPublic)
                {
                    object[] attr = field.GetCustomAttributes(typeof(SerializeField), true);
                    if (attr == null || attr.Length == 0)
                        continue;
                }

                if (field.FieldType.IsSubclassOf(typeof(Object)) || field.FieldType == typeof(Object))
                {
                    Object oldTarget = importer.GetDefaultReference(field.Name, out var instanceID);
                    if(oldTarget == null && instanceID != 0)
                    {
                        oldTarget = Object.CreateMissingReferenceObject(instanceID);
                    }
                    Object newTarget = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(field.Name), oldTarget, field.FieldType, false);

                    names.Add(field.Name);
                    objects.Add(newTarget);

                    if (oldTarget != newTarget)
                        didModify = true;
                }
            }
        }
        private void ShowFieldInfo(Type type, MonoImporter importer, List <string> names, List <UnityEngine.Object> objects, ref bool didModify)
        {
            if (!MonoScriptImporterInspector.IsTypeCompatible(type))
            {
                return;
            }
            this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
            FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            FieldInfo[] array  = fields;
            int         i      = 0;

            while (i < array.Length)
            {
                FieldInfo fieldInfo = array[i];
                if (fieldInfo.IsPublic)
                {
                    goto IL_67;
                }
                object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(SerializeField), true);
                if (customAttributes != null && customAttributes.Length != 0)
                {
                    goto IL_67;
                }
IL_EC:
                i++;
                continue;
IL_67:
                if (!fieldInfo.FieldType.IsSubclassOf(typeof(UnityEngine.Object)) && fieldInfo.FieldType != typeof(UnityEngine.Object))
                {
                    goto IL_EC;
                }
                UnityEngine.Object defaultReference = importer.GetDefaultReference(fieldInfo.Name);
                UnityEngine.Object @object          = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(fieldInfo.Name), defaultReference, fieldInfo.FieldType, false, new GUILayoutOption[0]);
                names.Add(fieldInfo.Name);
                objects.Add(@object);
                if (defaultReference != @object)
                {
                    didModify = true;
                    goto IL_EC;
                }
                goto IL_EC;
            }
        }
		private void ShowFieldInfo(Type type, MonoImporter importer, List<string> names, List<UnityEngine.Object> objects, ref bool didModify)
		{
			if (!MonoScriptImporterInspector.IsTypeCompatible(type))
			{
				return;
			}
			this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
			FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo[] array = fields;
			int i = 0;
			while (i < array.Length)
			{
				FieldInfo fieldInfo = array[i];
				if (fieldInfo.IsPublic)
				{
					goto IL_67;
				}
				object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(SerializeField), true);
				if (customAttributes != null && customAttributes.Length != 0)
				{
					goto IL_67;
				}
				IL_EC:
				i++;
				continue;
				IL_67:
				if (!fieldInfo.FieldType.IsSubclassOf(typeof(UnityEngine.Object)) && fieldInfo.FieldType != typeof(UnityEngine.Object))
				{
					goto IL_EC;
				}
				UnityEngine.Object defaultReference = importer.GetDefaultReference(fieldInfo.Name);
				UnityEngine.Object @object = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(fieldInfo.Name), defaultReference, fieldInfo.FieldType, false, new GUILayoutOption[0]);
				names.Add(fieldInfo.Name);
				objects.Add(@object);
				if (defaultReference != @object)
				{
					didModify = true;
					goto IL_EC;
				}
				goto IL_EC;
			}
		}
 private void ShowFieldInfo(System.Type type, MonoImporter importer, List<string> names, List<UnityEngine.Object> objects, ref bool didModify)
 {
   if (!MonoScriptImporterInspector.IsTypeCompatible(type))
     return;
   this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
   foreach (System.Reflection.FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
   {
     if (!field.IsPublic)
     {
       object[] customAttributes = field.GetCustomAttributes(typeof (SerializeField), true);
       if (customAttributes == null || customAttributes.Length == 0)
         continue;
     }
     if (field.FieldType.IsSubclassOf(typeof (UnityEngine.Object)) || field.FieldType == typeof (UnityEngine.Object))
     {
       UnityEngine.Object defaultReference = importer.GetDefaultReference(field.Name);
       UnityEngine.Object @object = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(field.Name), defaultReference, field.FieldType, false, new GUILayoutOption[0]);
       names.Add(field.Name);
       objects.Add(@object);
       if (defaultReference != @object)
         didModify = true;
     }
   }
 }
 private void ShowFieldInfo(System.Type type, MonoImporter importer, List<string> names, List<UnityEngine.Object> objects, ref bool didModify)
 {
     if (IsTypeCompatible(type))
     {
         this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
         foreach (System.Reflection.FieldInfo info in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
         {
             if (!info.IsPublic)
             {
                 object[] customAttributes = info.GetCustomAttributes(typeof(SerializeField), true);
                 if ((customAttributes == null) || (customAttributes.Length == 0))
                 {
                     continue;
                 }
             }
             if (info.FieldType.IsSubclassOf(typeof(UnityEngine.Object)) || (info.FieldType == typeof(UnityEngine.Object)))
             {
                 UnityEngine.Object defaultReference = importer.GetDefaultReference(info.Name);
                 UnityEngine.Object item = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(info.Name), defaultReference, info.FieldType, false, new GUILayoutOption[0]);
                 names.Add(info.Name);
                 objects.Add(item);
                 if (defaultReference != item)
                 {
                     didModify = true;
                 }
             }
         }
     }
 }