Giter Club home page Giter Club logo

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

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?

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

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

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!

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.

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

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.

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!

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.

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"
    },

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.

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?

[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

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.

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

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

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.

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

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.