Coder Social home page Coder Social logo

classtypereference-for-unity's Introduction

Type References for Unity3D

openupm

A plugin that allows you to choose types from a drop-down menu in the inspector.

screenshot

This is a fork of the currently inactive project by Rotorz: ClassTypeReference for Unity

Installation

❗ Before installing the package, please disable the Assembly Version Validation option in Player Settings.

Install with OpenUPM

Once you have the OpenUPM cli, run the following command:

openupm install com.solidalloy.type-references

Or if you don't have it, add the scoped registry to manifest.json with the desired dependency semantic version:

  "scopedRegistries": [
    {
      "name": "package.openupm.com",
      "url": "https://package.openupm.com",
      "scopes": [
        "com.solidalloy",
        "com.openupm",
        "org.nuget"
      ]
    }
  ],
  "dependencies": {
    "com.solidalloy.type-references": "2.15.1"
  },

Install via Package Manager

Project supports Unity Package Manager. To install the project as a Git package do the following:

  1. In Unity, open Project Settings -> Package Manager.
  2. Add a new scoped registry with the following details:
  3. Hit Apply.
  4. Go to Window -> Package Manager.
  5. Press the + button, Add package from git URL.
  6. Enter com.solidalloy.type-references, press Add.

Simple Usage

Types can be assigned via inspector simply by using TypeReference:

using TypeReferences;

public class ExampleBehaviour: MonoBehaviour
{
    [SerializeField] private TypeReference greetingLoggerType;
}

 

Usually, you would want to choose between two or three classes that extend a common parent class or implement certain interface. Use [Inherits] attribute for such cases:

using TypeReferences;

public class ExampleBehaviour: MonoBehaviour
{
    [Inherits(typeof(IGreetingLogger))]
    public TypeReference greetingLoggerType;
    
    [Inherits(typeof(MonoBehaviour))]
    public TypeReference onlyMonoBehaviours;
}

 

TypeReference can be used in place of System.Type most of the time:

TypeReference greetingLoggerType = typeof(DefaultGreetingLogger);
var logger = (IGreetingLogger) System.Activator.CreateInstance(greetingLoggerType);
logger.LogGreeting();

But if you need to refer to the System.Type object directly, use the Type property:

bool isLoggerAbstract = greetingLoggerType.Type.IsAbstract;

Tip Instead of the mouse, you can use arrow keys to navigate the hierarchy of types in the dropdown menu and press Enter to choose a type!

TypeOptions Attribute

If you need to customize the look of the drop-down menu or change what types are included in the list, use the [TypeOptions] attribute.

Presentation of drop-down list can be customized with the Grouping enum:

  • Grouping.None - No grouping, just show type names in a list; for instance, "Some.Nested.Namespace.SpecialClass".

  • Grouping.ByNamespace - Group classes by namespace and show foldout menus for nested namespaces; for instance, "Some > Nested > Namespace > SpecialClass".

  • Grouping.ByNamespaceFlat (default) - Group classes by namespace; for instance, "Some.Nested.Namespace > SpecialClass".

  • Grouping.ByAddComponentMenu - Group classes in the same way as Unity does for its component menu. This grouping method must only be used for MonoBehaviour types.

For instance,

[TypeOptions(Grouping = Grouping.ByAddComponentMenu)]
public TypeReference greetingLoggerType;

 

There are situations when you need to include a few types in the drop-down menu or exclude some of the listed types. Use IncludeTypes and ExcludeTypes for this:

[Inherits(typeof(IGreetingLogger), IncludeTypes = new[] { MonoBehaviour })]
public TypeReference greetingLoggerType;

[TypeOptions(ExcludeTypes = new[] { DebugModeClass, TestClass })]
public TypeReference productionType;

 

You can hide the (None) element so that no one can choose it from the dropdown.

[TypeOptions(ShowNoneElement = false)]
public TypeReference greetingLogger;

Note that the type can still be null by default or if set through code.

 

By default, only the types the class can reference directly are included in the drop-down list.

public class ExampleBehaviour
{
    // If this gives an error because it cannot find CustomPlugin type
    public CustomPlugin plugin;
    
    // Then CustomPlugin will not be in the drop-down.
    public TypeReference pluginType;
}

You can use the IncludeAdditionalAssemblies parameter to add all types of a particular assembly to the dropdown:

[Inherits(typeof(IAttribute), IncludeAdditionalAssemblies = new[] { "Assembly-CSharp" })]
public TypeReference attribute;

Or you can use the ShowAllTypes parameter to show all types defined in the project. But beware that it can create a large list with a lot of types you'll never need.

[TypeOptions(ShowAllTypes = true)]
public TypeReference AnyType;

 

If you are not satisfied with the auto-adjusted height, you can set the custom one with the DropdownHeight option. Use it like this:

[Inherits(typeof(IGreetingLogger), DropdownHeight = 300)]
public TypeReference greetingLoggerType;

 

By default, folders are closed. If you want them all to be expanded when you open the dropdown, use ExpandAllFolders = true:

[TypeOptions(ExpandAllFolders = true)]
public TypeReference allTypes;

 

You can make the field show just the type name without its namespace. For example, in this case, the field will show DefaultGreetingLogger instead of TypeReferences.Demo.Utils.DefaultGreetingLogger:

[Inherits(typeof(IGreetingLogger), ShortName = true)] public TypeReference GreetingLoggerType;

 

The SerializableOnly option allows you to show only the classes that can be serialized by Unity. It is useful when creating custom generic classes using the types selected from the dropdown. It is a new feature in Unity 2020.

[SerializeField, TypeOptions(SerializableOnly = true)]
private TypeReference serializableTypes;

 

AllowInternal option makes internal types appear in the drop-down. By default, only public ones are shown.

 

Inherits Attribute

This attribute allows you to choose only from the classes that implement a certain interface or extend a class. It has all the arguments TypeOptions provides.

[Inherits(typeof(IGreetingLogger))]
public TypeReference greetingLoggerType;

[Inherits(typeof(MonoBehaviour))]
public TypeReference onlyMonoBehaviours;

// All the TypeOptions arguments are available with Inherits too.
[Inherits(typeof(IGreetingLogger), ExcludeNone = true)]
public TypeReference greetingLoggerType;

 

If you need to have the base type in the drop-down menu too, use IncludeBaseType

[Inherits(typeof(MonoBehaviour), IncludeBaseType = true)]
public TypeReference onlyMonoBehaviours;

 

By default, abstract types (abstract classes and interfaces) are not included in the drop-down list. However, you can allow them:

[Inherits(typeof(IGreetingLogger), AllowAbstract = true)]
public TypeReference greetingLoggerType;

 

Project Settings

Some options are located in Project Settings.

By default, the field shows built-in types by their keyword name instead of the full name (e.g. int instead of System.Int32). You can change this by setting the Use built-in names option to false.

The searchbar appears when you have more than 10 types in the dropdown list by default. You can change this behaviour with the Searchbar minimum items count option.

Show all types - search for types in all assemblies located in the project, instead of in assemblies referenced by the type's assembly. It's disabled by default, and can be enabled per field with the [TypeOptions(ShowAllTypes = true)] attribute. But if you need this feature in all type references, feel free to enable it here.

Contribution Agreement

This project is licensed under the MIT license (see LICENSE). To be in the best position to enforce these licenses the copyright status of this project needs to be as simple as possible. To achieve this the following terms and conditions must be met:

  • All contributed content (including but not limited to source code, text, image, videos, bug reports, suggestions, ideas, etc.) must be the contributors own work.

  • The contributor disclaims all copyright and accepts that their contributed content will be released to the public domain.

  • The act of submitting a contribution indicates that the contributor agrees with this agreement. This includes (but is not limited to) pull requests, issues, tickets, e-mails, newsgroups, blogs, forums, etc.

classtypereference-for-unity's People

Contributors

danamador avatar felipesflisboa avatar kruncher avatar max99x avatar semantic-release-bot avatar solidalloy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

classtypereference-for-unity's Issues

UPM reference breaks after every update

изображение

I get this error for the second time now after I started using your package a couple of weeks ago. Looks like every time you post an update, reference gets broken. Are you force-pushing and removing commits by any chance?

My manifest.json:
"com.solidalloy.type.references": "https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git#upm",

My packages-lock.json:

"com.solidalloy.type.references": {
      "version": "https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git#upm",
      "depth": 0,
      "source": "git",
      "dependencies": {},
      "hash": "ee232e4028c8d8e6ad9b55c26828fcbefc924fc2"
    },

NullReferenceException for MonoScript asset

Hi there,

First of all, i'm really grateful to you for developing this feature, very very very useful for unity, i' use it everywhere(<3).

Unfortunately i'm opening this issue because at first usage of these scripts i found unity editor giving to me this errors
image

with the result that my component serialization in inspector is broken as shown in following image
image

Unity console lead me to this location(Runtime/TypeReference.cs:132):
image

Possible solution could be the usage of null-conditional operator:
image

In my case this fix works perfectly.
Thanks in advice.

Empty DropDown

Hello!

I tried to add [SerializeField] private TypeReference test to MonoBehaviour with and without [Inherits] but dropDown is always empty =(

I tried 2.6.2 and 2.1.0 ver

Unity 2019.4 11 and 2020.1 8

macOS Big Sur

DLL conflicts with Cysharp packages

DLL conflicts with Cysharp ZString and ZLogger and Type-References. Both you and Cysharp are including system DLLs in the package and they seem to be of different version, resulting in conflicts.

I made a test in an empty project (2021.1.0b4). Installing ZString OR ZLogger in combination with Type-References results in DLL conflicts. I wrote to them as well but what's your take on this? What is the best solution?

Suggested by SolidAlloy here: #23 (comment)

The following workaround seems to work:

  1. Remove System.Buffers.dll and System.Runtime.CompilerServices.Unsafe.dll from the Plugins folder.
  2. Disable "Auto Reference" and "Validate References" in System.Memory.dll
  3. In ZString.asmdef, enable "Override References" and add the following DLLs:
  • TypeReferences_System.Buffers.dll
  • TypeReference_System.Runtime.CompilerServices.Unsafe.dll
  • System.Memory.dll

I tried using both TypeReferences and ZString after that and got no errors in the console. Deleting DLLs in the TypeReferences folder should also work, but it would require making the plugin an embedded package, so deleting DLLs in the Plugins folder is easier.

@Cysharp can you please check on this and suggest your solution? Is there a way to modify your and/or @SolidAlloy packages to avoid conflicts and workarounds? Thanks a lot!

[ClassExtends(typeof(T)] on Lists not rendering properly in editor window

Hi,

It seems like this is valid:

public class UnitSpawnData : ScriptableObject
    {
        ...
        [SerializeField, ClassExtends(typeof(UnitModifier))] public List<ClassTypeReference> modifiers;
    }

(No errors are thrown when I execute code to add / remove items from the list). However...

Expected behaviour:
[SerializeField, ClassExtends(typeof(UnitModifier))] public List<ClassTypeReference> modifiers;
will allow me to add and remove child classes of UnitModifier in the inspector.

Actual behaviour:
My inspector drawer for the modifiers list contains: None and nothing else.
image

GUID conflict

This issue was closed in 2020, but it seems to still be present now. I installed the package using the Unity Package Manager instructions, and it seems to compile and work just fine, but these error messages reappear on every run of the game.

GUID [e7be1c9624387604fba4005ccf7dbd5a] for asset 'Packages/com.solidalloy.util/Runtime/SerializableCollections/SerializableDictionary.cs' conflicts with:
'Assets/SerializableDictionary/SerializableDictionary.cs' (current owner)
We can't assign a new GUID because the asset is in an immutable folder. The asset will be ignored.

GUID [91da51d02ab9ebc459d80d5965d40d19] for asset 'Packages/com.solidalloy.util/Editor/PropertyDrawers/SerializableDictionaryPropertyDrawer.cs' conflicts with:
'Assets/SerializableDictionary/Editor/SerializableDictionaryPropertyDrawer.cs' (current owner)
We can't assign a new GUID because the asset is in an immutable folder. The asset will be ignored.

The following workaround seems to work:

The following workaround seems to work:

  1. Remove System.Buffers.dll and System.Runtime.CompilerServices.Unsafe.dll from the Plugins folder.
  2. Disable "Auto Reference" and "Validate References" in System.Memory.dll
  3. In ZString.asmdef, enable "Override References" and add the following DLLs:
  • TypeReferences_System.Buffers.dll
  • TypeReference_System.Runtime.CompilerServices.Unsafe.dll
  • System.Memory.dll

I tried using both TypeReferences and ZString after that and got no errors in the console. Deleting DLLs in the TypeReferences folder should also work, but it would require making the plugin an embedded package, so deleting DLLs in the Plugins folder is easier.

Let's wait for a reply from Cysharp, they may suggest a better idea.

Originally posted by @SolidAlloy in #23 (comment)

GetAll is not allowed to be called from a MonoBehaviour constructor

So right after installing this package and opening demo scene I encountered this error:

UnityException: GetAll is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'ExampleBehaviour' on game object 'GameObject'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEditor.PackageManagerUtilityInternal.GetAllVisiblePackages (System.Boolean skipHiddenPackages) (at <d1bec46880064709a5e713ad543e6d96>:0)
UnityEditor.AssetDatabase+<FindEverywhere>d__30`1[T].MoveNext () (at <d1bec46880064709a5e713ad543e6d96>:0)
UnityEditor.AssetDatabase+<FindAllAssets>d__27.MoveNext () (at <d1bec46880064709a5e713ad543e6d96>:0)
System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].ToArray () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
UnityEditor.AssetDatabase.FindAssets (UnityEditor.SearchFilter searchFilter) (at <d1bec46880064709a5e713ad543e6d96>:0)
UnityEditor.AssetDatabase.FindAssets (System.String filter, System.String[] searchInFolders) (at <d1bec46880064709a5e713ad543e6d96>:0)
UnityEditor.AssetDatabase.FindAssets (System.String filter) (at <d1bec46880064709a5e713ad543e6d96>:0)
TypeReferences.ClassTypeReference.GetClassGUID (System.Type type) (at Library/PackageCache/com.solidalloy.type.references@b6bcf4cad2/Runtime/ClassTypeReference.cs:111)
TypeReferences.ClassTypeReference.set_Type (System.Type value) (at Library/PackageCache/com.solidalloy.type.references@b6bcf4cad2/Runtime/ClassTypeReference.cs:77)
TypeReferences.ClassTypeReference..ctor (System.Type type) (at Library/PackageCache/com.solidalloy.type.references@b6bcf4cad2/Runtime/ClassTypeReference.cs:59)
TypeReferences.ClassTypeReference.op_Implicit (System.Type type) (at Library/PackageCache/com.solidalloy.type.references@b6bcf4cad2/Runtime/ClassTypeReference.cs:88)
Example.ExampleBehaviour..ctor () (at Assets/Samples/Type References/1.0.0/Demo/ExampleBehaviour.cs:13)

Everything else seems to works as intended though. I'm using Unity 2020.1.2f1

TargetFramework issue with other packages

When installed with given instructions, opening c# project of a unity project with vscode, it gives primary referenced version of framework is 4.8 but package target framework is 4.7.1, it could not be resolved error. While the project and omnisharp works fine after loading, it gives some projects have trouble loading error.

Would this type of error affect builds or is there any way to make UnityEngineInternals with target framework 4.7.1 for all other packages to work with it?

The type 'MonoScript' is defined in an assembly that is not referenced.

Getting this error when installing via UPM or OpenUPM.

Library\PackageCache\[email protected]\Editor\Extensions\MonoScriptExtensions.cs(82,35): error CS0012: The type 'MonoScript' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Unity 2019.4.18f1, x64, Net 4.x, etc.

Not working due to GUID conflicts in meta files

GUID [19ddc7d736e94dd4853498fdde12dfab] for asset 'Packages/com.solidalloy.type.references/Editor/TypeDropDownDrawer.cs' conflicts with: 'Packages/com.solidalloy.type.references/Editor/TypeDropDown.cs' (current owner) We can't assign a new GUID because the asset is in an immutable folder. The asset will be ignored.

GUID [c0e325679500419d8f39d99aba58baba] for asset 'Packages/com.solidalloy.type.references/Editor/TypeFieldDrawer.cs' conflicts with: 'Packages/com.solidalloy.type.references/Editor/TypeField.cs' (current owner) We can't assign a new GUID because the asset is in an immutable folder. The asset will be ignored.

NullReferenceException

(This is the first issue I'm reporting on github. Pls excuse if I'm doing something wrong.)

I'm getting this NullReferenceException when I use TypeReference in a script.

NullReferenceException: Object reference not set to an instance of an object
TypeReferences.Editor.Util.SerializedTypeReference.get_GuidAssignmentFailed () (at Library/PackageCache/com.solidalloy.type-references@2371ab02f1/Editor/Util/SerializedTypeReference.cs:38)
TypeReferences.Editor.Util.SerializedTypeReference.FindGuidIfAssignmentFailed () (at Library/PackageCache/com.solidalloy.type-references@2371ab02f1/Editor/Util/SerializedTypeReference.cs:75)
TypeReferences.Editor.Util.SerializedTypeReference..ctor (UnityEditor.SerializedProperty typeReferenceProperty) (at Library/PackageCache/com.solidalloy.type-references@2371ab02f1/Editor/Util/SerializedTypeReference.cs:25)
TypeReferences.Editor.Drawers.TypeReferencePropertyDrawer.DrawTypeReferenceField (UnityEngine.Rect position, UnityEditor.SerializedProperty property) (at Library/PackageCache/com.solidalloy.type-references@2371ab02f1/Editor/Drawers/TypeReferencePropertyDrawer.cs:39)
TypeReferences.Editor.Drawers.TypeReferencePropertyDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/com.solidalloy.type-references@2371ab02f1/Editor/Drawers/TypeReferencePropertyDrawer.cs:25)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /home/bokken/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /home/bokken/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:165)
UnityEditor.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:112)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /home/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Editor/Inspector/InspectorElement.cs:539)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

The Serialization therefore does not work.
I first used TypeReference in a ScriptableObject and thought, that it might be incompatible. But the same error occured, when I tried it with a normal MonoBehaviour script.

I would love to use this package, as it's exactly what I need in my current project. Therefore I hope that there's a simple fix for this issue!
Thank you!

edit: I'm on 2020.3.12f1

Only works with scriptable objects for me

Hi, first of all I really want to compliment you for this very udefull and handy library for unity, is really well done.

Now, mi problem is that i found impossible to use in this context:

[RequireComponent(typeof(Rigidbody))]
public abstract partial class Entity : MonoBehaviour
{
	[TypeReferences.Inherits(typeof(MonoBehaviour), AllowAbstract = false, ExcludeNone = true, IncludeBaseType = false)]
	[SerializeField]
	protected MonoBehaviour MyType = null;
}

because this will result in errors in unity log tab:
NullReferenceException: Object reference not set to an instance of an object TypeReferences.Editor.Util.SerializedTypeReference.get_GuidAssignmentFailed () (at Library/PackageCache/[email protected]/Editor/Util/SerializedTypeReference.cs:41) TypeReferences.Editor.Util.SerializedTypeReference.SetGuidIfAssignmentFailed () (at Library/PackageCache/[email protected]/Editor/Util/SerializedTypeReference.cs:66) TypeReferences.Editor.Util.SerializedTypeReference..ctor (UnityEditor.SerializedProperty typeReferenceProperty) (at Library/PackageCache/[email protected]/Editor/Util/SerializedTypeReference.cs:23) TypeReferences.Editor.Drawers.TypeReferencePropertyDrawer.DrawTypeReferenceField (UnityEngine.Rect position, UnityEditor.SerializedProperty property) (at Library/PackageCache/[email protected]/Editor/Drawers/TypeReferencePropertyDrawer.cs:39) TypeReferences.Editor.Drawers.TypeReferencePropertyDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/[email protected]/Editor/Drawers/TypeReferencePropertyDrawer.cs:25)

It maybe caused by using the partial class?
Outside this context, like in other non partial classes it works perfectly..

Here is what i found with debugger attached and hovering the inspector
image

Thank you in advice

README still references old package name com.solidalloy.type.references

After noticing that GitHub had more recent releases than my UPM-installed version, I've noticed that there are two packages available on upm:

  1. com.solidalloy.type.references with latest: 2.8.0 (the old one)
  2. com.solidalloy.type-references with latest: 2.11.5 (the correct one)

It must be due to package namespace renaming that left an old reference for retrocompatibility. The old namespace doesn't even have a page on UPM website, only the new name has a URL: https://openupm.com/packages/com.solidalloy.type-references/

So it would be nice to change the README to reflect the new name, and also add a warning about the old name in case some people search it manually with openupm-cli and pick the wrong one.

UIElements Or Checking When Value Has Changed

So I'm currently using https://github.com/alelievr/NodeGraphProcessor. The nodes use UIElements to draw their inspectors and while it does draw the dropdown field I can't get events via RegisterValueChangeCallback or RegisterCallback. When the field is set I want to auto generate an object of that type.

Do you think it would be possible to create a UIElement implementation (IMGUI and UIElement coexist, whatever's drawing chooses which one it prefers)? I don't mind pitching in, just want to know if it's feasible first.

If not do you know the best way to implement a listener for field changes?

Cannot install due to to invalid dependencies

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git]:
Package com.solidalloy.type-references@https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git has invalid dependencies or related test packages:
com.solidalloy.unity-dropdown (dependency): Package [[email protected]] cannot be found [NotFound].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

[Package Manager Window] Error adding package: https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Note: Yes, I did install SolidUtilities first. Currently, SolidUtilities has its own error preventing it from compiling correctly, which I have submitted an issue for on SolidUtilities's page. That may possibly be because of this error.

Freezing Issues Inside VisualElement Container

2022-10-03-01-26-19.Type.Reference.Bug.webm

The above gif shows that after using the TypeReference selector I can no longer edit anything on that inspector window. The way to unfreeze it is to click a different window and back or to click and drag.
It seems this issue is caused by being inside a VisualElement container as it works fine within IMGUI.

EDIT: Whoops. Imagine I'd just opened the TypeReference menu before the GIF starts.

Cant import sample

Helppp
I just installed the package via openupm to a fresh Unity 2020.2 project, then adding samples to the project. And got these errors.

I use version 2.13.0 - February 08, 2022
Thank you!

Screen Shot 2022-03-02 at 00 06 22

NullReferenceException when adding asset via GenericUnityObjects

NRE seems to be caused because you're trying to access Event.current from outside OnGUI. Here's the stacktrace:

NullReferenceException: Object reference not set to an instance of an object
TypeReferences.Editor.TypeDropdown.SelectionTree.set_SelectedNode (TypeReferences.Editor.TypeDropdown.SelectionNode value) (at Library/PackageCache/[email protected]/Editor/TypeDropdown/SelectionTree.cs:65)
TypeReferences.Editor.TypeDropdown.SelectionTree.SetSelection (TypeReferences.Editor.TypeDropdown.TypeItem[] items, System.Type selectedType) (at Library/PackageCache/[email protected]/Editor/TypeDropdown/SelectionTree.cs:124)
TypeReferences.Editor.TypeDropdown.SelectionTree..ctor (TypeReferences.Editor.TypeDropdown.TypeItem[] items, System.Type selectedType, System.Action`1[T] onTypeSelected, System.Int32 searchbarMinItemsCount, System.Boolean hideNoneElement) (at Library/PackageCache/[email protected]/Editor/TypeDropdown/SelectionTree.cs:50)
GenericUnityObjects.Editor.ScriptableObjects.SelectionWindow.OneTypeSelectionWindow.GetSelectionTree (GenericUnityObjects.Editor.Util.NonGenericAttribute attribute, System.Action`1[T] onTypeSelected) (at Library/PackageCache/[email protected]/Editor/ScriptableObjects/SelectionWindow/OneTypeSelectionWindow.cs:32)
GenericUnityObjects.Editor.ScriptableObjects.SelectionWindow.OneTypeSelectionWindow.OnCreate (System.Action`1[T] onTypeSelected, System.String[] genericArgNames, System.Type[][] genericParamConstraints) (at Library/PackageCache/[email protected]/Editor/ScriptableObjects/SelectionWindow/OneTypeSelectionWindow.cs:22)
GenericUnityObjects.Editor.ScriptableObjects.TypeSelectionWindow.Create (System.Type genericTypeWithoutArgs, System.Action`1[T] onTypesSelected) (at Library/PackageCache/[email protected]/Editor/ScriptableObjects/TypeSelectionWindow.cs:37)
GenericUnityObjects.Editor.ScriptableObjects.GenericSOCreator.CreateAsset (System.Type genericTypeWithoutArgs, System.String fileName) (at Library/PackageCache/[email protected]/Editor/ScriptableObjects/GenericSOCreator.cs:33)

I'm using Unity 2020.3.19f1 and version 2.11.1 of your packages

Unsupported type TypeReference

Hey there. First of all, super awesome job with this. I am very happy I found your repo. I was about to submit a much more serious issue ticket on the older repos because the dropdown wasn't working at all. Your repo seems to have fixed that issue.

Here is the issue:
If I setup a TypeReference field on a component, then every time ANY changes are made in the inspector to ANY field (including TypeReference) it throws the following:
Unsupported type TypeReference

The stack traces vary depending on the field that I update. But here is the stack track when I update a TypeReference field:
image

Again, the choosing of Type and using it in script during runtime works as advertised. Just keep getting these errors when changing data in editor is all.

My setup:
Unity 2020.3.1
HDRP 10.3.2
Input System 1.0.2
Odin Plugin for Inspector and Serializations

Build Settings:
Standalone. MacOS & PC x86_64
IL2CPP - Min stripping
.NET 4.7.1

If you need any other information, please let me know. I'd be happy to help you debug this issue. Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.