Closed YacineFenina closed 9 years ago
Hi,
I'm not sure what you mean with "list of custom class without any inheritance." - if you have an object of type X, then you can only assign values to it that 'is a' X - not just any arbitrary value.
You can create an instance of an object (System.Object class or struct) by "Right clicking" on the 'circle' icon (the same one that you 'left click' to show the selection window)
Try that and let me know how it goes!
Thanks a lot. Actually I'm working with genericity and inheritance don't worry. Right click worked well. Thank you :) I may miss it in documentation.
Actually, with a simple class it works with left click : I can choose my Type (no need to right click ) But, with generic, you have to right click. Is there any reason for that ? In the window opened with left click I can only choose "Default" ?
Right click is just a shortcut to quickly instantiate your object. Assuming X is the type of your object, and X is not abstract, when you do Right Click I do: "myObj = new X()" - Left click gives you more options to choose from. - I cannot automatically create an instance of your class field cause if you collapse it and there's a cycle reference you'll end up in an infinite loop cause I don't have check for cycles. This won't happen if you manually create an instance of your field via Right Click.
On 31 May 2015 at 11:11, YacineFenina notifications@github.com wrote:
Thanks a lot. Actually I'm working with genericity and inheritance don't worry. Right click worked well. Thank you :) I may miss it in documentation.
Actually, with a simple class it works with left click : I can choose right Type (no need to right click ) But, with generic, you have to right click. Is there any reason for that ? In the window opened with left click I can only choose "Default"
— Reply to this email directly or view it on GitHub https://github.com/vexe/VFW/issues/23#issuecomment-107230219.
OK thank you, I understand :) That's a good reason ! You say that left clic give me more options, but I can't create instance, I just see Default field There is no generic in System.Type
Hmm, what's your field type?
On 31 May 2015 at 13:17, YacineFenina notifications@github.com wrote:
OK thank you, I understand :) That's a good reason ! You say that left clic give me more option, but I can't create instance, I just see Default field Not my generic Type
— Reply to this email directly or view it on GitHub https://github.com/vexe/VFW/issues/23#issuecomment-107241268.
Let's say I have a class A which inherit from Object.
This class has 2 generic parameter K and G K inherit from BetterScriptableObject G inherit from BetterScriptableObject< K >
I try to generate a List< A < K , G > >
This is my type :)
When you left click, it tries to find types that inherit A, if there's none, you'll only get the 'default (null' option.
So let's say I have class B, which inherits A < MySO1, MySO2 >, now when you have fields of A < X, Y > and left click you should see 'B' as an option - otherwise you just use Right click.
Btw that's such a complex generic relation, are you sure it needs to be that complex? :)
Haha,
I want to give it a try. I wondered if that's not too much dirty but it answers well to my waiting
Actually, I forget to explain you this part : I do have a class B that inherit from A But it doesn't display B at all
Can you post a simplified version of the code you're using?
On 31 May 2015 at 13:35, YacineFenina notifications@github.com wrote:
Haha,
I want to give it a try. I wondered if that's not too much dirty but it answer well to my waiting Actually, I forget to explain you this part. I do have a class B that inherit from A But it doesn't display B at all
— Reply to this email directly or view it on GitHub https://github.com/vexe/VFW/issues/23#issuecomment-107242129.
File A :
public abstract class SimpleType1
{
}
public abstract class GenericType<K>
where K : SimpleType1
{
}
public class MyData<K,G>
where K : SimpleType1
where G : GenericType<K>
{
[Serialize]
public G myObject;
[Serialize]
public List<K> myList;
}
public abstract class A<K,G> : BetterScriptableObject
where K : SimpleType1
where G : GenericType<K>
{
[Serialize]
public List<MyData<K,G>> myList;
}
File B :
public class InheritedGenericType : GenericType<SimpleType2>
{
}
public class SimpleType2 : SimpleType1
{
}
public class B : A<SimpleType2,InheritedGenericType>
{
}
That's complex, I hope that's just for testing :P
Which one of these is the object you're inspecting? I assume A< K, G > ? - if so, then the List list element type MyData < K,G > has no relation with A, it's inside A, not 'is a' A so you won't see 'B' when creating elements for that list when left clicking.
"B" would only show up if you had a field of type A < SimpleType2, InheritedGenericType > i.e.
public class Test
{
public A < SimpleType2, InheritedGenericType > myField; // you should see B here when you left click
}
And btw you don't need [Serialize] if the field is public :)
Actually I inspect a B asset. Your drawer doesn't show subclass ?
That's for testing but ... but I really hope to use it for some project :P it works well for the moment ...
For the public field I know, I just like to write it ... Is it heavier ?
Nop not heavy, just letting you know it's optional on public field :)
So if I understand well, if I didn't see anything else is because, I don't have any choice else but my inheriting class ?
Try this:
public class A
{
public int aValue;
}
public class B : A
{
public int bValue;
}
public class C : B
{
public int cValue;
}
public class Test : BetterBehaviour
{
public A a; // you should get A, B, C as options
public C c; // you will only get C
}
Get the idea? :)
Yep I get the idea. =) But I can't explain why my example doesn't show
What do you expect to see? the type 'B'? - You won't because it inherits A < SimpleType2,InheritedGenericType > and not MyData < SimpleType2,InheritedGenericType >
I thought I could see MyData In your example, we can see C displayed in the window
Just thought it should show something :)
Right. It should show it. Will fix in next push.
Ok :D Thanks for your work. That's really powerfull.
Hello,
Thanks again for your last answer. I have an other issue with editor viewer. I'd like to get a list of custom class without any inheritance.
For the moment, when I click on the add button I have a new box with written "null" inside and "Member value is null" in a sub box. I can do it with a struct but not with a class ..
I think I miss something about your work :)
Thanks in advance