Shimizoki
❔ [Unity?] How to have a list of generic classes in inspector cast as derived class
The thing that I'm working on is about to go down that nasty rabbit hole of having 50 of the exact same item, with no changes between any of them except for the types.
Each of these items has a boilerplate copy and paste, and then in half a dozen places scattered around the code base needs to have the exact same chunk of code copied and then the names changed for this item.
My goal is to prevent that. Maybe my starting premise was wrong to begin with
78 replies
❔ [Unity?] How to have a list of generic classes in inspector cast as derived class
I am absolutely happy to change as many things as necessary here. I even have some ability to change the actual functionality of the class. Maybe I can find a way to not use that add function at all.
I'm just really looking for a way that I can have all of these different objects in an enumerable of some kind
78 replies
❔ [Unity?] How to have a list of generic classes in inspector cast as derived class
I changed it to a ReadOnlyCollection, and then removed the nullability errors by adding a constructor. But I still get the invalid cast at runtime.
https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwAIAYAEqCMAWAbgFgAoDbHAOgGEB7AG3oFMBjYAS1qgGdKB5AEYArVsACytOE3rESpAIYDuwMPLbYATJjHywAayZgAklGCGAZmqaYA3gF8FSlWuCbtug2ADKLMOwAOwIrMtg5kWjr6hjiYIO5RxqYWVqGkqBEehlpxkZ4mZmCWLNb2aVo+foHBTDE5md6+AUECIaXhmBVN1dnxnp1VLSVhpKTsSYUpRgAqqiwGcLmG3AA8tBCuUzCYAKoAfKSYh5gA7gAWhtZTsb2G/c3MB0dnFzvXi4kFRUykNo+HuFgggBzWyYIFMYAETBhI7YADMmCurhsYIhUJhR1QCIASkx5HA+FB6ABPOiMUScKDLPaYCCg8GQ6GkYYkMafSYzNTzd7cXH+WjLTY7XbXaazbn1FZCvZ/E7nMCXN71O7VWXPBWvOoJfLJYo/WWoPCYACCcDgAAptrSAJSyFnpRHipgLSWCrY0uJirnOnl8gXS/YkWHqxVavqNAYPINPeXWK1hww6iZ6ki/aP/BEAzDA+lozDcPMYjOI7O5xkFxlF+GYXH4wkksnMNiU6kiukohlQivo2X+PwAN3kZkwABl2MpW5gAPrt1Hlwuyg2Zo2mi1WiDWtqwxfp6ucuY+yXmq5jKfAa2ytOw2E5gC8mAARA/ZNejq576fIbLYTPMPeoEwxyjuOwCtuatrfkcdL/oBNZ4gSRKkgwTYcFwYEzhBu5hPaWi4AA7Pqu64AAbNgRo6GM4GXpBhyDmAmD0CBf6YABQG4HglBjhOXoHi6CS8kw/LLO8KqDFs7xJl8uy7OBL6vpgNEdBG9w1PmMQwUBonMDgsmKYxyiUKu5qsY63p8Z4Kwicp1TifUklWDJ3A4NamHyQpu6wnRmAsPIyjOsx5o8RK/F+ssWk1LZCQ4Ls1r6cAADa6AALpyYc2FAA
78 replies
❔ [Unity?] How to have a list of generic classes in inspector cast as derived class
Falling some other examples online. I attempt to split my interface into a covariant, and a contravariant part. No dice
https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwIYCMDOwyoMbAAEAAgEyECyqYA1gKZgCSUwDAZvnQLABQA3rwC+vXhmy4CJclVoMAynjABLAA7AMAG278hInmUrV6YAIyEQh2UxbtOhXgJ7CevAzOPkL7hs1ZgOeNqOzq7kCspqmnRmXkbyiqrq6FoOui76YQmRyXSelsbhiVGpTnp6Sjb+dowAKhL0cN5gmAA8APYQRDUwhB1EAKoAfLyEo4QA7gAWDHSENeb58RFJKTxjE9Ngs/0LTb62gSXrxCYADITqAOaEfISXdMAA3ITOxwDMcxc3dw/Pr2PED79ADaAF1CBBvvcni80rwKn4ArNavU6I04s0AEp0FRtFrdQhDBYo/ANJqtAlDEZjKYzT6xKyFbKrda0raE3YY/ZVQ46NYAgAshAAgnA4AAKHYQACUjzhGTmqPRVgpPSJFhJeDJGMw2Nx+LVw35ozZs3mDIKWRW2lZm22nKs3KRRwBHxO5yuUN+hEw3v+o0BnyIt2hz19MP9JCBYIhXph4b+1NGSajJCFoolUulfGcIQVJwA7C6AyYAGxpwwVcXSlOOdbrABu1EIGiU2EIAF5CFA6OMSCYBQA6AAybeALU12pVerxTSZ1p6e0qSMGg2rcuN9db2EHGfFPb7dVJaPJLTnVqii65y84a+lspT60fYybYEIeFQ2DRncI4snJ51GcWnnKITCvKwTEGaVt2AYFTlBDd1lzIA=
78 replies
❔ [Unity?] How to have a list of generic classes in inspector cast as derived class
https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwIYCMDOwyoMbAAEAAgEyECyqYA1gKZgCSUwDAZvnQLABQA3rwC+vXhmy4CJclVoMAynjABLAA7AMAG278hInmUrV6YAIyEQh2UxbtOhXgJ7CevAzOPkL7hs1ZgOeNqOzq7kCspqmnRmXkbyiqrq6FoOui76YQmRyXSelsbhiVGpTnp6Sjb+dowAKhL0cN5gmAA8APYQRDUwhB1EAKoAfLyEo4QA7gAWDHSENeb58RFJKTxjE9Ngs/0LTb62gSXrxCYADITqAOaEfISXdMAA3ITOxwDMcxc3dw/Pr2PED79ADaAF1CBBvvcni89McACyEACCcDgAAodhAAJSPNKhOb1OiNOLNFrdQhDBa1QnEqytclDEZjKYzT6xKyFbKrdYsrYU3Yk/ZVQ46NYAj4nc5XKG/QiYWX/UaAz5EW7Q57ymGKkhAsEQmUwzV/JmjE06kiIlHozFYvjOEIZEgmADsRwBJgAbBbDBU0VizY51usAG7UQgaJTYQgAXkIUDo4yd8IAdAAZSPAFrU/ANJqtJqclZ0Hp7SoBOiDQZ+3FioPhjPJq1o+OJuo5ol5loFrJFkuCsucKtYnFm9ajsahsCEPCobBEmOENHZvC5kmtQtREx9qwmQZYiPYYGnUE19b2oA==
With a little bit of tweaking I was able to get this error. But it's warning me that I can't be Co and contravariant... I think
78 replies