#Unity stripping UVS at BuildTime in core project

1 messages · Page 1 of 1 (latest)

pseudo olive
#

Hi. Our pipeline is centred around AssetBundles.

We have our main app built by a remote team, and our team of tech-artists prepares AssetBundles for this app, and we do so in a separate project. This means whenever we write a new script, we need to submit it to the devs and they will add it to the App for us. I thought we could have a little more freedom if we used UVS, but after asking devs to add it, and they did, and using it on our end to produce a test bundle, the UVS did not work and I saw this in LogCat.

I'm not sure exactly what's going on here, but it looks like despite UVS having been added, the same Unity version (2021.1.16f1) and the same UVS package version (1.6.1), the ScriptMachine and Variables on my GameObject are still not being read in our app.

All I can guess at the moment is that UVS is being stripped when our devs build because nothing in their project is using it (because only the bundles we produce would). Anyone have any wisdom to share here? Or anyone better know what our problem is exactly?

fiery zinc
#

I dont have experience with this stuff but from searching you could try this if you have not already:

Add a link.xml file
Unity looks at link.xml during build to know which types/assemblies not to strip.
Place this in your Assets folder (or any Editor folder, Unity will pick it up):

<linker>
  <assembly fullname="Unity.VisualScripting.Core" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.Flow" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.State" preserve="all"/>
</linker>
pseudo olive
#

Thanks, X7. So it can go in Assets or an Editor folder?

I'm just reading this page where this guy talks about the link.xml, but I am confused what he means about Unity generating this during build then clearing it after, almost makes it seem like it won't help if I try to do it as well manually. I'm gonna try it though

#

Quite slow to solve problems like this cos I'm in New Zealand and many of our devs are either in India or Middle-East lol. One of them says they will try to generate a low and none stripping build for me so we can at least narrow down that stripping is the problem

fiery zinc
#

you can put it any where in the asset folder it does not have to be in a editor folder

pseudo olive
#

Nice, thanks

fading isle
#

Is it possible... that Latest unity 6.2 and uVS version could help?

#

I mean, you are sending a built, not an asset. Right?

pseudo olive
#

ah I doubt I'd be convincing our company to upgrade Unity anytime soon. I'm like.... the new tech-artist, globally distributed teams, various satellite companies working with/around the project and multiple SaaS layers all intertwined and dependant on plugins for this version, Unity app is wrapped in ReactNative just for fun, and via blockchain our assetBundles are also on a separate JavaScript driven VR platform in Unity. Upgrading Unity willl set the company on fire xD

#

Can confirm that the link.xml had no effect though :S

pseudo olive
#

I partly lie, it did progress us somewhat, instead of missing behaviour errors, got:

Failed to define InvokeMember#ca8b2...: System.MissingMemberException: No matching member found: 'Animator.SetInteger'
#

and similar no-matching-member errors....

#

gonna add a dummy C# file to see if it forces the members to be included at buildTime

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using TMPro;

public class UVSReflectionDummy : MonoBehaviour
{
    void Awake()
    {
        // ---------- Animator ----------
        Animator animator = null;
        animator?.SetInteger("", 0);
        animator?.Rebind();
        var updateMode = animator?.updateMode;

        // ---------- Renderers ----------
        Renderer renderer = null;
        renderer?.material = null;

        // etc
        // etc
        // etc
        // etc
        // etc
        // etc
    }
}
fiery zinc
pseudo olive
#

Well it probably does work, but we build assetBundles from one project, and app-builds from another

#

the app-build project never sees any of our graphs first-hand, so it never gets to step through them at pre-build

fiery zinc
#

oh ok i see so when the pre-build happens it cannot go through all of your graphs ok i see

pseudo olive
#

i don't see an obvious way around this one. I'd hoped the link file would be enough

#

Could have a master-graph in the app project lol....

#

just, if I have to go to devs and hand them a prefab or graph asset everytime, it defeats the purpose of introducing UVS to our pipeline lol

#

: to not have to go to dev team everytime we need to add scripted logic for any given asset

fiery zinc
#

I remember a while back someone needed help with something similar related to the visual scripting addons where it was not able to get all the types for a specific unit(because they were also using this same system where Visual Scripting could not see the graphs) and they way we got around it was Generating a script at pre-build for all possible types you could use so that the unit could work this would include unused types is the only problem but its not that bad, I would say we could try something similar but the problem is you would need to include every single type and its members(fields, methods etc) and the types alone i could imagine is in the 1000's to 10's of thousands. It was easier for us to do it because we only need the types that are Unity Event types. So this could be a possible solution but could be quite bad

pseudo olive
#

Yeah, well it looks like with the dummy C# script we have progressed from

Failed to define InvokeMember#ca8b2...: System.MissingMemberException: No matching member found: 'Animator.SetInteger'

to

Failed to define GetMember#dede5...:
System.NotSupportedException: The member type is not valid for this unit.

So I assume that means it's not hung up about specific method now, rather it just wants....... every member

#

that's an insane demand xD

#

I'm crazy enough to do it, but the dev helping me on this is gonna get fed up with my constant "can you try this?" pretty soon ^^;

#

Soon I'll ask about our company's build process so I don't have to bug devs for my experiments anymore

fiery zinc
#

Yea this is a problem hey, How do you guys connect your graph work with the main project? Do you use version control to share it or do they have to add each file manually, do you build the graphs in a separate Unity project and then hand them over so the devs can add them into the real project ? or some other way?

pseudo olive
#

We have an AWS that we upload assetBundles to. We deal in NFTs and users access a catalogue of 3D assets and they can arrange their collectibles in their own multi-user "showrooms"

#

showroom at the scene level is just a list of model-ids and other parameters, when the scene load it pulls from AWS

#

the assetBundles themselves, that we upload to AWS are just typical prefabs, usually of a single model with anims and fx, some interactions

#

so the project itself never needs to see any assets, only once its built and users start pulling bundles from AWS.
App download is small, but loadtime comes into it as showroom populates from server

#

This sums it up

fiery zinc
pseudo olive
#

yep

#

if the app needs it built-in, gotta go through dev team

#

i wouldn't mind that, it's not a dealbreaker

#

still better than having to go through them for every little script lol

#

and then if I realize I need to change 1 line of code in that script later.....

#

not to mention debugging, for a standalone home project you typically just add logs, no big deal, but if i add logs, gotta submit to devs again

#

this why i so badly wanted a more interpreted scripting solution lol

#

LUA, JS or C# Roslyn solutions are out there, but having to craft all the interop from scratch is a dealbreaker for the pace we have to work at

#

UVS seems great because it already mirrors Unity so well

fiery zinc
#

Yea, This is quite a complicated problem hey

pseudo olive
#

My dev helper guy is trying another build, this time with a unitypackage I sent him of the asset I'm testing with today

#

in theory it has all the nodes, and should provide the info for the pre-build

#

I'd love for it to work, but even then it's a bit of a logistics issue going forward

pseudo olive
#

no luck, so.... even if the build has my graph it still can't do it? Starting to think the problem isn't entirely stripping afterall

#

I'm gonna setup 2 projects this weekend to simulate how our work does it, and see if I can have a more first-hand try at understanding what exactly is going on here

pseudo olive
#

hm, though I did tell him to just included it in the project, and not a scene, unless that still gets stripped and it still needs to actually be in a built scene

#

so far, a C# script with dummy members has been the best result so far

#

Just I can't even fathom a C# script that includes every member I'd need from all classes.... that'd be like including all of Unity codebase inside of unity's codebase, meta-unitycodebase

fiery zinc
# pseudo olive Just I can't even fathom a C# script that includes every member I'd need from al...

yeah, i was thinking of doing something like this:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.VisualScripting;
using UnityEngine;

[InitializeAfterPlugins]
public static class GenerateUVSReflectionDummy
{
    static GenerateUVSReflectionDummy()
    {
        Codebase.settingsChanged += Generate;
    }

    private static void Generate()
    {
        var types = typeof(UnitBase).GetField("options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null) as HashSet<IUnitOption>;

        foreach (var type in types)
        {
            if (type == null) continue;

            if (type is IMemberUnitOption unitOption)
            Debug.Log($"[UVSReflection] Generating for type {unitOption.member}");
        }
    }
}

then writing the member to the file so that way you atleast don't have to do it manually and everytime you add or remove a Type from the type options it could regenerate the file

#

So it would have the case of still including unused types but at least you only add the types that are meant to be used in UVS(Type Options) so you don't go overboard with adding all types from all assemblies or something similar

pseudo olive
#

If that works, that'd be sic

#

In theory, that looks to me like it could work as is

fiery zinc
#

yeah i am try to see if i achieve it ive gotten quite close there are just alot of cases that needs to be handled but it seems like i am almost done

pseudo olive
#

Shall I sit tight? Sounds like you're cookin somethin

fiery zinc
#

yeah

fiery zinc
#

Oh woops wrong script just give me a sec opening the Generated file destroys my PC so i needed to close everything

pseudo olive
#

Man you do such good work with UVS, Unity owes you a few paychecks lol

fiery zinc
pseudo olive
#

Thanks man. 2:30am in India atm so I'll have to wait a bit for dev to be awake, but will have him try it asap 😄

fiery zinc
#

You're welcome. maybe i should have asked this earlier though when it "Worked" for you. You did not need the script to run right because the way it generates everything is basically null and does not do null checks so it would throw errors if it runs. The file just needed to be in the project?

fiery zinc
pseudo olive
#

I actually never had it 'working', only progressed from one batch of errors to the next

#

I'd say the furthest we got was this output

Failed to define GetMember#dede5...:
System.NotSupportedException: The member type is not valid for this unit.
fiery zinc
pseudo olive
#

so that was after ensuring Animator type, and specific methods I was using (Rebind(), Play()) and specific member properties (playbackType) were included, it looks to me as though it had accepted those, but moved on to complain about every other member, even ones I wasn't using

#

tbh I am not sure what exactly it is/was complaining about

#

but yeah, file just needed to be in the project

#

the important part i guess is just that it is part of one of the assemblies being built

fiery zinc
#

I see a lot to do with the serialization of the types so what could be the problem is that in your project(or where ever the graphs are built) all the types are serialized but in the devs project its not so when it tries to deserialize the type/member it cannot find it

pseudo olive
#

and this above is not a build error, it's logcat output at the moment i try to import assetBundle

pseudo olive
#

That was after adding this file to Assets

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using TMPro;

public class UVSReflectionDummy : MonoBehaviour
{
    void Awake()
    {
        // ---------- Animator ----------
        Animator animator = null;
        if (animator != null)
        {
            animator.SetInteger("", 0);
            animator.Rebind();
            var updateMode = animator.updateMode;
        }

        // ---------- Renderers ----------
        Renderer renderer = null;
        if (renderer != null) { var m = renderer.material; }

        MeshRenderer meshRenderer = null;
        if (meshRenderer != null) { var m = meshRenderer.material; }

        SkinnedMeshRenderer skinned = null;
        if (skinned != null) { var m = skinned.material; }

        SpriteRenderer sprite = null;
        if (sprite != null) { var m = sprite.material; }

        LineRenderer line = null;
        if (line != null) { var m = line.material; }

        TrailRenderer trail = null;
        if (trail != null) { var m = trail.material; }

        ParticleSystemRenderer psr = null;
        if (psr != null) { var m = psr.material; }

        // ---------- Physics ----------
        Rigidbody rb = null;
        if (rb != null) { var k = rb.isKinematic; }

        Rigidbody2D rb2D = null;
        if (rb2D != null) { var bt = rb2D.bodyType; }

        Collider col = null;
        BoxCollider box = null;
        SphereCollider sphere = null;
        CapsuleCollider capsule = null;
        MeshCollider meshCol = null;
        Collider2D col2D = null;
        Joint2D joint2D = null;

        // ---------- Core ----------
        Transform t = null;
        Camera cam = null;
        Light light = null;
        ParticleSystem ps = null;


        //etc
        //etc
        //etc
#

Sample

#

that was after adding these to our existing link file

<linker>
  <assembly fullname="Unity.VisualScripting.Core" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.Flow" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.State" preserve="all"/>
</linker>
#

Which I initially did as a response to this feedback in LogCat when importing AssetBundle

#

so you can see, we did actually progress a little way through error batches

#

so dying to see where your tool puts us 😄

pseudo olive
pseudo olive
fiery zinc
fiery zinc
#

I will look through the code to see if thats the case

pseudo olive
#

ah, it shouldn't be the case, that would be like if the assetbundle imported a type unknown to the project

pseudo olive
# pseudo olive

Which I thought the first batch of errors was about where it complained about missing behaviours

#

I suspect im still missing a key understanding here though, because you're right, many of the errors in my latest version ARE to do with serialization of types

fiery zinc
fiery zinc
pseudo olive
#

I see, I actually tried sharing a unitypackage with him too so he could have one of my prefabs that included my graph, I think for that test I needed to actually included it in a built scene, which we didnt do though.... only thought about it after

#

what's annoying is the logs dont seem to be telling me what types exactly they are struggling with

fiery zinc
pseudo olive
#

my messages were a bit all over the place there

#

this, definitively, is what i call our furthest progress

fiery zinc
#

ok i see let me see if i can trace its execution

pseudo olive
#

sample

fiery zinc
#

well you might be able to find it if the GUID stays the same let me check quick

pseudo olive
#

I'd have to cross my fingers for that, seeing as this is the result of import and sometiems Unity just reassigns when importing things

#

though there is project import and runtime import

fiery zinc
pseudo olive
#

a painful thing is i dont have a clear way to test IN Unity.

Our app is triggered by ReactNative and I'm not privvy to the full build pipeline

#

cant even initialize our AssetBundle import stuff in the Unity project alone

#

so i cant import assetBundle and easily click/view things like GUID, and I can't add a test script for this cos it has to go through a review process and i would then have to wait for the next staging build a week later before i can try my log

#

id just use UVS to log but....

fiery zinc
pseudo olive
#

i can in the unity project where we build the app

#

that app then gets thrown into CI and wrapped in ReactNative, and that produces the app we can try on our phones

#

but yes, i can access the graph file in our project, but i cant test importing the asset at runtime

fiery zinc
#

I don't think you will need to import it all you need is the graph file that you can view in the graph window so you can do this

#

So you can see at the bottom of each node it shows the GUID that's what we are trying to see, but if you don't have access to the Graph at Edit time then that's unlucky we will have to find a different solution

pseudo olive
#

I may do, I might just not understand, I'll lay it out how I interpret what you're saying

#

I have our tech-art project where we produce all this stuff, models, anims, vfx, shaders, and hopefully: graphs

#

and there is the app project, which i or my team normally have nothing to do with, but i CAN import packages to it for local testing

#

that all ya mean?

pseudo olive
fiery zinc
#

well yeah i think so i can try to describe a bit better to make sure

What we need is the project that has the Visual Scripting graphs in it we don't need the graph at runtime or anything we just need to be be able to view the units

pseudo olive
#

oh ok, I do that in the techart project, yeah, but im not sure how i'd confirm the GUIDs after exporting and importing to app

fiery zinc
#

i am assuming you've closed the project sometime after the latest test for at least a bit so you reopen it and the Unit has the same GUID that should mean it does not change so we might be able to do what we need

pseudo olive
#

good thinking. It's reopening as we speak

fiery zinc
#

it depends on how many graphs you have though because searching for it can take a long time if you have a lot

pseudo olive
#

for now, just one

fiery zinc
#

ok

pseudo olive
#

this is my proofcase so i can convince our boss we can use it

fiery zinc
#

what you will need if you don't know how to use dev mode Just go to Edit > Preferences > Visual Scripting > Developer mode and turn it on

pseudo olive
#

ah nice, yeah didnt know, cool

fiery zinc
#

So once you do that try to find the Get Member node that has a GUID that starts with dede5

pseudo olive
#

kk

#

nice, a few interesting settings here, Human Naming, I don't need that at all but it's on by default

#

Max Search Result 100..... what search results? It has search? In my home projects I use a third-party package for that

fiery zinc
#

its when you use recursion let me send a pic

pseudo olive
#

What's AOT Safe Mode meant to do? I wish one of these meant "make it work for our asset bundle pipeline"

#

a few settings I'd LOVE to know the meaning of

fiery zinc
pseudo olive
#

nice, thx for explaining that

fiery zinc
fiery zinc
#

It might do more but I am not 100% sure

pseudo olive
#

just trying to track down dede5

fiery zinc
#

oh ok so thats the Unit that's causing the problem

pseudo olive
#

or at least one of them lol

#

there are 2 other instances of "failed to define" in that output from before

fiery zinc
# pseudo olive or at least one of them lol

yeah i am just trying to see what's different about it because the log says that the member type is not valid meaning it could be trying to use something like a InvokeMember, Set Member or a Indexer so let me have a look.

pseudo olive
#

or I needed to literally include renderer.materials, where I have only included renderer.material

#

if that is the case, it probably will be covered by your tool

#

cos it steps through all properties of all types yeah?

fiery zinc
#

Ok so this is failing:

    protected override bool IsMemberValid(Member member)
    {
        return member.isAccessor && member.isGettable;
    }

which is very weird

because isAccessor

        public bool isAccessor
        {
            get
            {
                switch (source)
                {
                    case Source.Field:
                        return true;
                    case Source.Property:
                        return true;
                    case Source.Method:
                        return false;
                    case Source.Constructor:
                        return false;
                    default:
                        throw new UnexpectedEnumValueException<Source>(source);
                }
            }
        }

it returns true for both field or property, so if this is failing which i doubt its because now visual scripting is thinking that the accessor is a Method or Constructor

this is more likely the problem:

        public bool IsGettable(bool nonPublic)
        {
            switch (source)
            {
                case Source.Field:
                    return nonPublic || fieldInfo.IsPublic;
                case Source.Property:
                    return propertyInfo.CanRead && (nonPublic || propertyInfo.GetGetMethod(false) != null);
                case Source.Method:
                    return methodInfo.ReturnType != typeof(void) && (nonPublic || methodInfo.IsPublic);
                case Source.Constructor:
                    return nonPublic || constructorInfo.IsPublic;
                default:
                    throw new UnexpectedEnumValueException<Source>(source);
            }
        }

but even still everything should be staying the same which could point back to the serialization problem it might give the incorrect infomation to the member because renderer.material is a property and would only fail if its not gettable which it is

#

Oh i don't know how well you know C# so hopefully you understand

fiery zinc
pseudo olive
fiery zinc
#

if i did all types the file would probably end up being Gb's in size increasing your app size to that

pseudo olive
#

I suspected only including singular material, not array materials in my UVSReflectionDummy was a problem, but that doesn't explain why Animator.updateMode would fail, that one IS included in my dummy

fiery zinc
#

yeah does it fail with the same warning?

pseudo olive
#

These 2 are renderer.materials

#

this one is animator.updateMode

#

seems same to me

#

but i just realized I failed to notice these

#

those ones are all the same type

#

those are all of them, i think the rest is a summary

#

that covers ALL of the UVS errors in the log

fiery zinc
# pseudo olive These 2 are `renderer.materials`

oh these are because the nodes are not defined so their ports do not get added to the Unit so it does not load the connection between them if we fix these the connection problem would fix its self

pseudo olive
#

right, fixing the former probably fixes the latter

#

and am i right about the last bit? It's just a summary and compile of crash report?

fiery zinc
#

mine does not add the specific code that the prebuilder adds

pseudo olive
#

and the prebuilder is the part that relies on seeing your graphs in order to understand what to include, right?

fiery zinc
#

yeah

pseudo olive
#

I'm gonna try with your tool anyway, will still be really curious how far it gets us

fiery zinc
#

you could manually trigger the prebuilder and send that to the dev aswell

pseudo olive
#

but that prebuild thing might be a bit of a brick wall..... asset-bundle pipelines typically dont include assets in the project itself, that'd defeat the purpose of having an assetbundle pipeline

#

cos we keep build-size down and users just download the assets for content they're actually accessing

pseudo olive
#

we make a new branch per asset, or per group of assets

#

these assets are never in the same branch as each other, because some might be from marvel, some from paramount etc. We do this to keep branches small so that fixing things doesnt take a lot of load time

#

so when we are working on exporting new... say... Teletubbies assets, we'll make a new branch, setup the assets, export them to the cloud, then move on to other assets on a different branch, almost never revisiting that branch ever again unless we get bug reports for it

#

which means I can probably never run the prebuilder such that I could provide anything definitive for the dev

#

itd only ever be for the assets pertaining to that branch

fiery zinc
#

i see

pseudo olive
#

WIll be about 12hrs before I can test your tool with dev ^^

fiery zinc
#

So it would need the generated script with all types but using the special code of the prebuilder

#

oh ok cool no problem

pseudo olive
#

I'm crossing my fingers a lot, I was hoping your script generator might trick it into filling the void left by the prebuild step

fiery zinc
#

Same tbh, i guess right now there is alot if's and guesses we will need to wait to see what happens

pseudo olive
#

yeah

#

ty so much, you were under zero obligation to help me as much as you have! Now it's a waiting game

fiery zinc
#

You're welcome!

pseudo olive
#

This is the second company I have worked at where we have an AssetBundle Pipeline

#

At previous company, we used PlayMaker, all nodes/actions are predefined, there is no reflection, and therefore no guesswork by the engine

#

so everything built in the app no problem, and on the bundling side we just trusted everything we used would be there

#

But PlayMaker is 100% state-machine, it's a real mountain of a task to complete certain game-style features this way

#

so I really hoped the convenience of UVS would leave it in the dust

fiery zinc
pseudo olive
#

as a result, it's missing many of the things you expect from Unity's codebase

fiery zinc
#

oh ok i see

pseudo olive
#

I made my own node graph in IMGUI once, but problem quickly became that if I wanted every Unity feature or at least my own way to relay unity features, it's like creating a custom node for everything. Such a pain, UVS got released half-way through me making that, so I abandoned all my work and switched to UVS instead lol

fiery zinc
#

Wow ok! I don't know what FF7 is but that looks really cool!

pseudo olive
#

Final Fantasy from 1997 lol

#

but yeah you can see in that post that the node graph is already pretty big

#

and that's ALL custom nodes, each one encompassing numerous things that'd be exponentially more if I wasn't using custom nodes

fading isle
pseudo olive
#

so from that, I really enjoyed doing things that way. And after really hating using PlayMaker at previous job, I thought it could be really cool if we could try UVS here

pseudo olive
#

I leverage TextMeshPro, it has a maxCharacter property

fading isle
fading isle
fiery zinc
pseudo olive
#

but yeah, my experiment there gave me a lot of faith in UVS

#

if only I could overcome these hurdles, I know our team would be away laughing with our pipeline

#

apparently licensors/clients here for years have only been shipping assets that are either static, have a singel animation, or a few tap-anims

#

only in past few months, and roughly since I've come along, things have ramped up and there is more need for logic to be added to assets too

#

the way they have been doing it cos they are only recently having to deal with this problem, is to write a script for assets that need it, but yeah it is a real pain having to wait a week to see the result and test it on staging

#

so im on the warpath to make that better

pseudo olive
#

at previous company we didnt have app wrapped inside reactNative, i was able to make my own builds quickly and write new c# scripts and test quickly

#

here, i need to wait till the devs have time to walk me through the build process with reactNative, maybe it ends up that we stick with C# submissions for now, but in that case I NEED for our team to be able to test faster, so we gonna have to learn build process if we can't get UVS goin

fiery zinc
pseudo olive
#

Oh, cool, I see that with developer mode on we can see some additional info for graphs serialized data too, maybe that will help in my prob solving if I only understood what it was telling me better

fiery zinc
#

Oh yeah forgot about that

pseudo olive
#

I wonder if it hates me doing this

#

its just... i tried to tell it what type it is, but unless i also hand it an object it clears the type

#

but i populate this at runtime, i dont wanna hand it an object during edit

#

I could hand it an object just to trick it maybe

#

still..... my errors are about renderer.materials, not a single material.... maybe it doesn't hate this afterall

fiery zinc
#

Yeah I doubt that changes much

pseudo olive
#

This is one of my faulty nodes from before

pseudo olive
#

not that i know what i should do about this though

fiery zinc
#

Yeah I am hoping that with the Generated Script it allows the type and members to be found because theres a chance that the member does not fully reflect so its source stays unknown because of this:

_source = Source.Unknown;

and this is not 1 of the 4 sources it supports

#

but then this would have trigger if thats the case

throw new UnexpectedEnumValueException<Source>(source);
#

It's getting quite late so I am going to go for now. I will see if i can find anything else tomorrow/later

pseudo olive
#

I hope for all your troubles it's at least interesting for ya lol. Thanks for everything! Night!

fiery zinc
pseudo olive
#

I'm trying a fresh test setup from a brand new project, see if I can reach success, bother my dev when I got something

fiery zinc
#

cool

pseudo olive
#

I'm trying out your script at the moment, it does generate the great big massive list of members

#

no compile errors, but billion build errors

#

i think it is possibly grabbing deprecated things too or something

#

I'm seeing if I can figure out a way to filter it a tad

fiery zinc
#

any chance you can show me the line where autoGenerate is generated

#

because i am able to access it so i want to see if its just not adding the type with its namespace so it cannot be found

#

and i did add a check for obsolete values it should not generate if it is

#

I will try to see what's going on there

fiery zinc
pseudo olive
#

Same result, I could go through and delete each of these lines though and see what happens

pseudo olive
#

maybe nothing to do with deprecation

#

maybe just certain ones that are editor only

#

cos it's all these, might just be able to do a sweep for common reoccurrances like this post-generate

fiery zinc
pseudo olive
#

it generates, but when ya try to build it complains

fiery zinc
#

ok i see

pseudo olive
#

thats why i suspect its pulling in all the editor stuff too and not wrapping it

#

which is not super-a-problem

#

ok, deleted the 239 offending lines, now lessee another build

fiery zinc
#

cool

pseudo olive
#

Good news, it wiped out all my UVS errors except the one you mentioned before could be a problem

#

Ignore my shader errors, that's just because idk wtf I'm doing with asset bundles in this fresh project. I don't need to fix shader issue because it's a solved problem at work

fiery zinc
#

i see then what i will have to do is make the generator generate these action invokers and accessors

pseudo olive
#

that is in relation to the editor includes?

fiery zinc
#

No but i am trying to find a connection to see what Unity uses to decide if its editor only so far it seems like this Might work i have to test it quick

    static bool IsEditorOnly(MemberInfo member)
    {
        var attrs = member.GetCustomAttributes(false);
        return attrs.Any(a =>
            a.GetType().Name == "NativeNameAttribute" ||
            a.GetType().Name == "NativeMethodAttribute");
    }
fiery zinc
pseudo olive
#

ghaw, if you don't work for Unity you absolutely should

#

I swear, you've single-handedly kept UVS out of the grave for years

fiery zinc
#

So related to the editor only stuff i could probably stop alot of them from generating but the problem is when its in a conditional like #if UNITY_EDITOR there is no way to detect this

pseudo olive
#

could lazily hardcode some, but I see that's not your go-to style lol. Because I think about half of them were 'runInEditMode'

#

and those that weren't 'often' had edit or editor in their name, you wouldn't wanna wipe any 'edit' stuff that isn't editor only though

fiery zinc
#

yeah this does seem to work

    static readonly Dictionary<Type, List<string>> EDITOR_MEMBERS = new Dictionary<Type, List<string>>()
    {
        { typeof(Graphic), new List<string>() { "OnRebuildRequested" } }
    };
    static bool IsEditorOnly(MemberInfo member)
    {
        MemberInfo baseMember = member;

        if (member is MethodInfo mi)
            baseMember = mi.GetBaseDefinition();

        if (EDITOR_MEMBERS.TryGetValue(baseMember.DeclaringType, out var editorMembers))
            return editorMembers.Contains(baseMember.Name);

        var attrs = member.GetCustomAttributes(false);
        return attrs.Any(a => a.GetType().Name == "NativeNameAttribute" || a.GetType().Name == "NativeMethodAttribute");
    }

now i just need to add the rest of the types

pseudo olive
#

nice, i shoulda sent you my log so you can see all of em

#

you get same errors if you build on your end though i assume

fiery zinc
#

i think so i might not have like 1 or 2 types so just incase you could send it

#

if possible

pseudo olive
#

mine was a blank project 😄

fiery zinc
#

oh ok then i probably have the same

pseudo olive
#

If only there was a way to spam all these into a graph as well

#

then that could take care of the prebuild

#

100% that graph should also never be opened by a human, lest lag descend from on high

fiery zinc
#

because i have access to the members

pseudo olive
#

god knows how far it goes, but you would know better than I lol

fiery zinc
# pseudo olive

I dont use AppDomain to get all assemblies i use

        var optionsField = typeof(UnitBase).GetField("options", BindingFlags.NonPublic | BindingFlags.Static);
        var options = optionsField.GetValue(null) as HashSet<IUnitOption>;

to find all types that UVS found that it can use(yes some of these are editor only or conditional ones but these can probably be filtered out)

and i know how to add units to the graph with code

pseudo olive
#

ah you already have a way then

fiery zinc
#

yeah but i can check out his prebuilder first

#

wow ok this is actually very similar to what i was trying right now

pseudo olive
#

neat

fiery zinc
#

like this

        readonly static HashSet<string> _excludedMembers = new(new[] {
            // Not available in runtime/platform assemblies
            "runInEditMode", // Components
            "imageContentsHash", // Textures
            "OnRebuildRequested", // UI

            // Unity/C# standard stuff we barely use (good optimization since it is present in most types)
            "GetInstanceID",
            "GetHashCode",
            "GetType"
        });
pseudo olive
#

oh that's pretty elegant

fiery zinc
#

I might be able to strip this version of his prebuilder and then just trigger it manually then you should have a working solution

pseudo olive
#

I thought GetInstanceID and GetType could be sorely missed but if I'm being honest I do barely use em

fiery zinc
pseudo olive
#

heck, if I'm using those, I'd be using CS, not UVS

#

nah, i agree they're a good optimization

#

most UVS ppl I see are using it for fun gameplay stuff, not gritty system stuff

fiery zinc
pseudo olive
#

oh very cool, brb just restarting comp

fiery zinc
#

So you can trigger it in Tools > Generate Prebuilder then you can test build

fiery zinc
pseudo olive
#

Ok, here goes, firing up unity etc etc

#

do I still use GenerateUVSReflectionDummy? Or does this replace it?

fiery zinc
#

This replaces it so if you still have that script you can delete it

fiery zinc
pseudo olive
#

These I don't have

#

because I'm in the past probably

fiery zinc
#

interesting seems like a older version can you show me the IAotStubbable

pseudo olive
fiery zinc
#

ok seems like you just replace GetAotStubs(visited) with aotStubs

pseudo olive
#

just cant pass visited to em then, hopefully not a major

fiery zinc
#

shouldnt be a problem it was probably handled fine(ish) when it was used like this

pseudo olive
#

building

#

buddy ol pal! I owe you a lifetime supply of mcdonalds

#

working! heck yeah!!!

fiery zinc
pseudo olive
#

Hooooly hell, what a sidequest this was. You carried, man!

fiery zinc
#

Yeah, was much more complicated than expected, but was actually quite fun!

pseudo olive
#

My dev buddy is gonna be pretty glad, and now we can get some tests out the door and tell our boss the good news, that we dont have to wait a week to test logic anymore ^^

fiery zinc
#

Nice! I guess if some how a error still creeps up out of nowhere you can let me know

pseudo olive
#

For sure! Thanks again man! I'll be hard pressed to find a way to return the favour

pseudo olive
#

and hopefully if anyone else seeks to bundle UVS in future, can mark this problem up as solved

fiery zinc
#

Oh yeah true

fiery zinc
fiery zinc
pseudo olive
#

Think I lack permissions

fiery zinc
#

oh i see

#

@fading isle maybe you able to pin them?

fading isle
fiery zinc
# pseudo olive Hi. Our pipeline is centred around AssetBundles. We have our main app built by ...

The problem could be something wrong with Visual Scripting's Linker file so to solve this problem you can add a link.xml file to your project and add this to the file

<linker>
  <assembly fullname="Unity.VisualScripting.Core" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.Flow" preserve="all"/>
  <assembly fullname="Unity.VisualScripting.State" preserve="all"/>
</linker>

If you are using Asset Bundles or a similar system where your graphs are not directly accessible at build time, you may see an error or log such as: Attempting to call method ... for which no ahead of time (AOT) code was generated In that case, add the GeneratePreBuilder script to an Editor folder in your project.

If you get a error saying "'IAotStubbable' does not contain a definition for 'GetAotStubs'" or something similar use the GeneratePreBuilder_Old script instead

Once added, go to Tools > Generate PreBuilder and make sure the generated file stays in your project (do not move it) when you build your game.

Thanks to colin-defais https://discussions.unity.com/t/visual-scripting-and-addressables/878637/6 for the pre-builder script.

pseudo olive
#

I don't have custom nodes in our company's project at the moment, but supposing I did go that way at some point..... would it be tough to add to this?

#

I might just avoid it lol, count blessings that we can script now

pseudo olive
#

Actually they might be fine as they sit in the same assembly as rest of codebase by default so they probably get counted

fiery zinc
pseudo olive
#

not a big reflection guy, it seems to have been a necessity for you to have as much of a handle on UVS as you do

#

but yeah I am unlikely to produce anything at this stage that uses reflection. It will mostly be things like "swap a character in your party" node that leverages explicit knowledge of defined types

pseudo olive
#

I'll keep that in mind though, sounds like a critical tidbit for someone at some point

pseudo olive
#

@fiery zinc to intentionally counter the additional buildsize this results in, does it suffice to remove unlikely types from typeOptions? Or we should configure nodeOptions as well?

#

(we're happy with the 10mb buildsize this adds, but asking just in case it comes up later)

fiery zinc
pseudo olive
#

Just for interest's sake. My dev said to me "When I use script, it makes LocationUses. And for that, I need to add Description in Location Uses Description in PlayerSettings"

#

I asked ChatGPT and ended up following its suggestion to also exclude these

    // --- Privacy-sensitive APIs (iOS / Android entitlements) ---
    // Location Services (requires NSLocationWhenInUseUsageDescription)
    "UnityEngine.Input.location",
    "UnityEngine.LocationService.Start",
    "UnityEngine.LocationService.Stop",
    "UnityEngine.LocationService.status",
    "UnityEngine.LocationService.lastData",
    "UnityEngine.Input.compass",

    // Microphone (requires NSMicrophoneUsageDescription)
    "UnityEngine.Microphone.Start",
    "UnityEngine.Microphone.End",
    "UnityEngine.Microphone.devices",

    // Camera / WebCam (requires NSCameraUsageDescription)
    "UnityEngine.WebCamTexture.Play",
    "UnityEngine.WebCamTexture.Stop",
    "UnityEngine.WebCamTexture.devices",

    // Bluetooth (can trigger Bluetooth privacy prompts)
    "UnityEngine.iOS.Device.advertisingIdentifier",
    "UnityEngine.iOS.Device.vendorIdentifier",

    // XR / AR subsystems (may require ARKit/VR entitlements)
    "UnityEngine.XR.InputTracking",
    "UnityEngine.XR.XRDevice",
    "UnityEngine.XR.XRSettings",
    "UnityEngine.XR.XRInputSubsystem",
    "UnityEngine.XR.Management.XRGeneralSettings",
    "UnityEngine.XR.ARSubsystems.XRCameraSubsystem",
    "UnityEngine.XR.ARSubsystems.XRSessionSubsystem",

    // Analytics / Ads identifiers (can trigger AppTrackingTransparency on iOS)
    "UnityEngine.Advertisements.Advertisement",
    "UnityEngine.Analytics.AnalyticsSessionInfo",
    "UnityEngine.Analytics.Analytics",

    // Contacts / Social APIs (rarely used, but privacy-sensitive)
    "UnityEngine.Social",
    "UnityEngine.SocialPlatforms.GameCenterPlatform",
fiery zinc
#

If so i can add the excludes

pseudo olive
#

it's ok, I added the above to the generator script as _excludedTypeMembers and our build is no longer asking as to add descriptions for location usage

pseudo olive
#

I mentioned to the dev that I can probably add a lot of stuff here if the 5mb gain in build filesize is a problem (but pretty sure it's not a problem)

#

seeing as there is definitely a lot our team aren't likely to ever interact with through UVS, like Cloth, BillboardAsset, LightmapSettings, Projector, OcclusionPortal etc

fiery zinc
pseudo olive
#

doh, lead dev did say "5mb should be acceptable but please minimize if it's an option to do so", ok, time to flex my copy/pasting skills

pseudo olive
#

basically just moving stuff from here into the excludes lol

fiery zinc
#

Ahh ok smart

pseudo olive
#

maybe I could add a keyword array to the generator that automatically does that

fiery zinc
#

How do you mean?

pseudo olive
#

I don't trust what I just said, ignore it lol. Actually, in the excludes do I need to add full paths? Can I add UnityEngine.LightProbeProxyVolume

#

instead of

fiery zinc
#

I think if you want to block entire types add it in this:

        readonly static HashSet<string> _excludedBaseTypes = new(new[] {
            "UnityEngine.LightingSettings" // Not available in runtime/platform assemblies
        });
pseudo olive
#

will do!

#

No harm if there is crossover between the _excludedBaseTypes and _excludedTypeMembers list eh?

fiery zinc
#

yeah it checks the baseTypes first so if the type is there is will skip checking the members and just exclude it entirely

#

If that makes sense

pseudo olive
#

nice

pseudo olive
#

do changes to Node Library in Player Settings > Visual Scripting impact the generator in any way?

fiery zinc
pseudo olive
#

Will it matter if I accidentally add strings to the HashSet that aren't valid types? Like where I might have blindly pasted a namespace not knowing much about it?

fiery zinc
pseudo olive
#

What's producing these exactly? the parts near the beginning with op_Equality, Inequality, Implicit etc

#

Despite me excluding all 2D types, and that does remove 3000 lines of this stuff further down where it's explicitly talking about

// --------------- Plugin Stubs
// --------------- Asset Stubs
// --------------- Scene Stubs
// --------------- Additional Stubs
#

but, these near the top, the 2D elements are still present

#

I've removed 2D things from my types and nodes in PlayerSettings

#

I get that it's here

#

but what do I change in my project settings to skip all these 2D things for example

#

Can't be from my packages, not including much there

fiery zinc
#

mmm not sure why but something I could do is just check if the type name contains 2D it can ignore it?

#

Ahh wait i think Node Library does have something to do with, try and remove all 2D related assemblies in the Node Library

fiery zinc
#

it was too big to send as code so had to send it as a file, but you can just copy and paste it

pseudo olive
#

Just doing a few build tests, I forgot that the C# file itself will contribute to filesize somewhat

pseudo olive
#

tbh it sounds like the dev was just interested if i CAN bring size down, but that he'll take whatever I end up with

#

this was before and after your help, ignore the number 2, that's actually before.

So there are 5mb for me to balance here

#

just by messing with the generator I've got variations of results like this

#

and I'll just do one now where I am explicitly removing unwanted stuff from PlayerSettings

pseudo olive
#

Does minifying help with Unity? Or does that become irrelevant because of IL2CPP and compilation

#

I'll test now with comments removed, just for curiosity

#

Removing stuff explicitly in PlayerSettings didn't change much, 12kb difference lol

#

I could be wrong, but guessing it could be because UnityEngine casts a pretty wide net and most of the real inclusion is coming from that

pseudo olive
#

this is countered by all the exclusions i added and made a slight change to ensure this carries between namespaces and types

#

so most of the filesize is dictated by the generator script it seems

#

will remove comments from generator now and test another build, just sharing my progress in case you're curious

#

I've brought back all the defaults in playersettings cos why-not-?, seeing as it wasn't impacting size much

#

While the C# file went from 7mb to 6mb without comments, I only got a few kb difference in my build... it was actually an increase, I swear that comments are all I changed for this regenerate.... well, in any case I conclude I needn't scrutinize the generated script when toiling over filesize

pseudo olive
#

@fiery zinc we're moving from Unity 2021 to Unity 2022.3 ^^;

So now I can check your pin which has the later version advice too. Wonderful! Ty again!

pseudo olive
#

@fiery zinc I'm getting the above error when I run the generator

#

and I think the only other major change has been this additional filter, I forget why I added it but I needed to

#

the last line of code before it steps beyond our script is here:

fiery zinc
pseudo olive
#

I was on 1.9.4 before but error appeared, that's why I switched to 1.9.8, I can try 1.9.5

fiery zinc
pseudo olive
#

I can try that

fiery zinc
pseudo olive
#

oh actually it's not letting me choose versions unlike other packages

fiery zinc
pseudo olive
#

gonna try your original version, without any of my modifications

#

ahyep, can confirm, issue is same

fiery zinc
fiery zinc
pseudo olive
#

I logged Codebase.settingsTypes and it's coming up null

#

kk will try show you that

fiery zinc
pseudo olive
fiery zinc
#

try regenerating the nodes see if that fixes it

pseudo olive
#

oh ok

#

just for info, I logged these

#

regenerating nodes now

#

that prob doesnt halp lol

fiery zinc
#

Oh so Visual Scripting is not initialized?

pseudo olive
#

guess that is as a result of changing packages or updating unity version

fiery zinc
pseudo olive
#

Success 🙂 ty!

#

Yeah I'm just not familiar enough with UVS requirements and all that lol. So small checklist things like this completely escape me I guess

fiery zinc
pseudo olive
#

yeah xD

good call haha

fiery zinc
pseudo olive
fiery zinc
pseudo olive
#

ahright

fading isle
pseudo olive
#

They limit the number of pins you can have per forum?

fading isle
#

We could create a pin in general thread and relink to important threads. And edit when needed. That could work as well

pseudo olive
#

Ah no that sounds messy longterm

#

Its ok. This pin not that important

#

How did you pin the last one?

fading isle
#

I didn't. Mods did it. Now I can do it too but it will override whats being pinned already

#

Maybe it helps?

pseudo olive
#

Hm, it's a bit different. Discord definitely allows pinning multiple messages in a thread. We're making use of it in other communities. Seems a bit of an arbitrary restriction for the sake of itself from Unity's end. To be clear, I'm talking about this feature

#

we definitely don't have that capability in unity discord channel?

pseudo olive
#

because the quicklinks are less for small messages, and more for large articles or resources

fading isle
#

Pinning messages inside a thread is not the same as pinning a post inside forum-type channels

#

Here's some things they mentioned about it as well.

pseudo olive
#

Ah i thought forum type channels were just decorated threads. Interesting