#↕️┃editor-extensions

1 messages · Page 37 of 1

atomic sable
#

did you try deleting your library folder?

daring glade
#

hmm... Honestly, in this case it sounds like it could be a fix for it. I will try and see

#

yeah, it seems to work so far! 👀 Thanks

snow pebble
#

i made a custom property drawer but i seem to get this in the inspector, no idea why

#

what does that usually suggest is wrong with it

#

i get no compile errors

#
    [CustomPropertyDrawer(typeof(TestMeshComponent))]
    public class TestMeshComponentPropertyDrawer : PropertyDrawer
    {
        static string[] sharedProps = { "Name", "Type", "Mesh", "Materials", "Layer", "IsStatic", "Offset" };
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var root = new VisualElement();

            PropertyField[] sharedFields = new PropertyField[sharedProps.Length];
            for (int i = 0; i < sharedFields.Length; i++)
            {
                sharedFields[i] = new (property.FindPropertyRelative(sharedProps[i]));
                root.Add(sharedFields[i]);
            }
            return root;
        }
    }
lean venture
#

Hi. I want to compute effect in Editor window too. I need access to transform-like component of the implicit editor camera at C# level. I need to extract location/fov/far plane/near plane of the Editor camera as read-only data. What API could I use in Unity 6.3 LTS? It's fine for my project to use undocumented and "likely to be changed in the future private C# API" .

surreal girder
dawn crescent
#

has anyone been getting this error when downloading a package Unity 6.3 LTS. Im trying to install unity recorder

gloomy chasm
#

Isn't there some trick with assembly definitions to allow you to access the internals of a package? Or am I misremembering?

short tiger
gloomy chasm
waxen sandal
#

There's also some specific assembly names that Unity has marked as friend assemblies

dusk dome
#

is there an equivalent to OnDrawGizmos for the editor window class?

dusk dome
#

so ima just do that

waxen sandal
#

Not sure Gizmos work in update?

dusk dome
#

its a bit finicky

waxen sandal
#

It sure is

dusk dome
#

i have to give each shape a lifetime

#

so it doesnt disappear

dusk dome
waxen sandal
#

VertxDebugging probably works similar but I have no idea about that package

dusk dome
cerulean raven
#

I am trying to create a custom editor window which shows a preview for each prefab in a library folder.

I tried using EditorSceneManager.NewPreviewScene to render the prefabs as textures. I created a new camera and did MoveGameObjectToScene, but rendering my camera still just renders my current active scene instead..

And I tried using a PreviewRenderUtility, but could never get it to work. I got it to show an image, but it was pitch black, no matter what I did with light settings/intensity(70k+). And I dont see my object at all, even when trying to give it an unlit shader.

Does anyone know how I can render a prefab as a texture onto my editor? I want it to look like this image. I already have it creating the buttons & images, just cant get the object rendering right..

#

And I cant just use the prefab's image itself, because I want to be able to change the color/material in my editor window and have the pieces all live update to that color in the window.

slender quiver
cerulean raven
cerulean raven
cerulean raven
#

I couldn't really get it working well, so I opted to use a camera.render to get a RenderTexture 1 time and save the image as a png in my asset browser, and then use a colouring function to change the icon colours instead of changing materials & re-rendering. I assume this might be faster anyways, but not sure.

Has to get each image from asset browser again, but doesn't have to re-render each image.

dusk dome
#

im trying to make a window, but when i expand things in the property drawer, it expands upwards and takes up space with the other buttons. How can i make it expand downwards?

#

never mind fixed it, the parent had flex grow incorrectly

surreal girder
#

Ongui defaults can be dumb so you often have to disable flex everywhere to stop this

kindred quest
#

Hi, i have this issue do you know if its a known bug ? And if it has a fix

safe sorrel
#

You're having networking issues.

kindred quest
#

wdym ? I have no network issues except for this

safe sorrel
#

It'd be possible for you to have a problem with Unity, but still be able to visit other websites

#

however, other people are having this problem

#

so it's probably not on your end!

kindred quest
#

k thank, i hope it will be fix before the end of the Global Game Jam 😅 🙏

safe sorrel
#

oh, that's really bad timing :x

vapid prism
#

If I have a ListView that's bound using binding-path how can I retrieve the target element if I override BindItem?

#

The default list view entry template contains a button that I'm trying to query for while retaining the "default" BindItem behaviour for the rest of the template

vapid prism
#

To answer myself:

dusk dome
#

How can I clear a property field?

#

I tried .Unbind() and .bindingpath = null but neither worked

digital spoke
#

I have a script that executes in both editor and playmode and handles the drawing of instanced grass on my custom terrain system. I've been noticing a constant detection of memory leaks on domain reload and I'm not sure how to solve it. I always dispose of the compute buffers whenever they're not in use (which in this case will be whenever the script is destroyed/disabled), should I be also disposing on domain reload as-well?

#

The memory leaks seem to ONLY occur on domain reload, they do not appear to happen on entering/exiting playmode.

surreal girder
digital spoke
#

Its a monobehaviour, yes

digital spoke
#

I tried releasing and then reinitializing the compute buffers using the OnAssemblyBeforeReload and OnAssemblyAfterReload. In OnAssemblyBeforeReload, I release the buffers and in OnAssemblyAfterReload I reinitialize them to the saved instance data of the terrain

#

But there's still a memory leak apparently

#

wait no, there doesn't appear to be a memory leak anymore. I was getting confused by an earlier leak detection in the console.

surreal girder
gusty mortar
#

Hi ! I know it's possible to automatically dock a window next to another one trough thise method EditorWindow.GetWindow<T>(params Type[] desiredDockNextTo) but is it possible to manipulate the tab order through code ?

#

Like, I'd like to ensure my window is always at second place or something like that

waxen sandal
#

Theoertically with lots of reflection probably

#

Or you can try manually editing m_Panes

#

@gusty mortar

gusty mortar
#

Ah nice, thanks for pointing the direction

digital spoke
#

Since this server doesn't have a shaders channel anymore I'm not really sure where to place this other than here.

I'm trying to write a custom render pass for URP which:

  • Renders the scene similar to a GBuffer but with some important differences (I can handle the 'differences' part)
  • Takes the resulting texture from the step above and creates a mask for outlines, which can then be sampled in a shader attached to an object

Documentation for writing custom render passes using render features (especially w/ render graph) is basically non-existant and was less than useless to me. I have no real idea on how to continue past making a basic skeleton class containing the scriptable render feature and the associated pass. I also looked at the URP samples you get from the package manager and they also didn't really help me figure out anything.

using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering.RenderGraphModule;

public class _3DPixelArtFeature : ScriptableRendererFeature
{
    [SerializeField] private _3DPixelArtFeatureSettings settings;

    private Shader _shader;
    private Material _material;
    
    private _3DPixelArtFeaturePass m_ScriptablePass;


    
    /// <inheritdoc/>
    public override void Create()
    {
        if (_shader == null)
        {
            _shader = Shader.Find("Custom/PixelArtNormalPass");
        }
        
        _material = CoreUtils.CreateEngineMaterial(_shader);
        m_ScriptablePass = new _3DPixelArtFeaturePass(settings)
        {
            renderPassEvent = RenderPassEvent.AfterRenderingOpaques,
        };
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        renderer.EnqueuePass(m_ScriptablePass);
    }

    [Serializable]
    public class _3DPixelArtFeatureSettings
    {
        
    }
    public class _3DPixelArtFeaturePass : ScriptableRenderPass
    {
        private readonly _3DPixelArtFeature._3DPixelArtFeatureSettings settings;

        public _3DPixelArtFeaturePass(_3DPixelArtFeature._3DPixelArtFeatureSettings settings)
        {
            this.settings = settings;
        }

        public void Setup(Material material, RenderTargetIdentifier source)
        {
        }

        public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
        {
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            //Render the scene similar to a GBuffer using the supplied shader & material
        }

        public override void FrameCleanup(CommandBuffer cmd)
        {
            if (cmd == null) return;
        }
    }
}
gusty mortar
short tiger
digital spoke
#

I looked at that, it didn't really help explain (infact, I'm pretty sure that's the exact thing I used to create the skeleton class I shared)

#

Everything I find that explains how to render to a custom pass that can then be sampled from another script is using old APIs that don't do anything in Unity 6. Think I'm just going to have to skip writing my own pass for now.

normal ermine
#

I know there are a lot of packages that allow for creating Hierarchy Folders. However, I wanted something very simple that I could give to my students and also practice making a Unity extension. And so I put together Simple Hierarchy Folder a simple little tool that does what it says.

If anyone would like to make use of it you can get it here https://github.com/ProfessorAkram/SimpleUnityHierarchyFolder?tab=readme-ov-file

Also feel free to let me know if any improvements could be made.
Thanks 😊

GitHub

Enables the creation of dedicated folder objects in the Unity hierarchy for cleaner, more organized scenes. - ProfessorAkram/SimpleUnityHierarchyFolder

chrome root
#

I wanted to work on my project when im not home so i copied it to a USB stick and boot it up on my laptop, downloaded the unity exnetsions to VS 2022 and yet the intellesense doesnt work, tried everything, regenerated my files 5 times, made sure im on the right external editor, repaired my vs twice and yet still nothing works, im stuck, any help please?

lean venture
surreal girder
toxic beacon
#

Good day

I'm not sure if this counts as an editor extension. I am getting lost. I have looked online, and I am unable to make heads of how I can do what I want to do.

I am busy building an editor window to create dialogue trees for my project. I am using it with the Unity localization system, pulling the dialogue strings directly from the localization table.

I am looking at a way to put the Localized String Picker in my editor Window.

toxic beacon
tardy crown
visual stag
# tardy crown

Your code doesn't compile, and your ide is not configured

#

!ide

dusty pineBOT
tardy crown
#

Right... how do I fix that?

visual stag
tardy crown
#

Forgive me for being stupid, but could you link me directly instead of making me search for it, I don't magically know exactly what you're talking about.

tardy crown
#

I have the editor package installed and up to date, and yet it still hasn't resolved the issues.

#

Seems I just forgot semicolons...

hallow locust
#

could i use C++ in Unity?

clear kite
# hallow locust could i use C++ in Unity?

Use in what way (and why)? Regardless the answer is likely no. There might be some asset that allows that to some degree but unity only supports C# as a scripting language by default

queen wharf
#

no

clear kite
#

C# is the only scripting language officially supported

queen wharf
clear kite
#

Is there a specific reason you want to use C++ over C#?

surreal girder
#

You can use cpp code but dont expect to interact with any unity apis. Its not like godot where its exposed

dense sedge
#

hi, im trying to make a scene-like hierarchy preview in an editor window and I;ve tried using PreviewRenderUtility to do it. I have an issue where the character doesnt render correctly and I was wondering if anyone maybe knew from this code snippet if I was perhaps missing something or whether the method I'm using just wouldn't work for this at all?

dense sedge
#

ok resolved it apparently by default Render doesnt allow scriptable render pipeline

snow pebble
#

how do you create an empty scene when using an editor tool so the rest of the scene is not in the way?

#

then restore it when you close the editor window

snow pebble
#

more like temporary hide everything in active scene

visual stag
#

I've not used it before (a custom stage), but the prefab stage has the capability to hide, fade, or isolate the other scenes

snow pebble
#

is there a way to know in an editor if a monobehaviour is inside the DOTS subscene vs regular scene? I need to display different UI if its part of DOTS or not so knowing the scene type it is part of is needed

brazen valley
zealous star
#

hey guys is there something like this: [CustomPropertyDrawer(typeof(List<CustomClass>))] ?
The custom class draws fine, I'm just trying to add labels to each index to match an enum's titles.

#

Basically just trying to replace "Element 0", "Element 1" with custom names

gusty mortar
bright phoenix
#

You can maybe make a drawer for the custom class that just draws a different name (if instance is part of a list) 🤔

zealous star
queen wharf
#

just a vibe check; im pretty sure there isn't a good way to do this (which is really shit)

zealous star
humble hearth
#

Hey guys, has anyone ever used an fbx modifying asset that transfers units to other units? For example, id like to fix some .fbx by converting cm to m

#

Cascedeur for some reason exports in cm, which is quite annoying as the rig is at a object scale of 100

real spindle
#

Select an FBX in unity and look at the inspector, IIRC the first 2 options are scale related

humble hearth
#

I figured it out

#

Had Claude make me an editor tool where I right click the fbx, and hit a button that automates fixing the scaling issue in blender

surreal girder
humble hearth
#

Claude/ai is trash for anything meaningful

surreal girder
#

unity can already alter scale on import and bake axis conversion so this seems a bit much

#

not that its useful to automate this kind of fix but not great long term

humble hearth
#

Exporting from my animation software left the rig in cm instead of m

#

So my animations werent retargeting

#

The animation software didnt let me apply unit scaling when exporting

surreal girder
#

Weird, humanoid anim retargeting should work if the bone hierachy fits the expected state

humble hearth
surreal girder
#

Ah well then you cannot use the humanoid rig mode

humble hearth
#

You can, hence why I need proper scaling

#

It works and this tool solves my problems

surreal girder
#

Ive not had much success before myself 🤔

#

Ive had extra bones in animations just not function till changing the mode back

#

But its been a few years

humble hearth
#

As long are your rigs are 1:1 it works just like generics with same rig animations

surreal girder
humble hearth
#

I cant be the modeler, animator, programmer, networker, and the blender/python tooler

#

Id rather just save myself the 2 hours of googling

#

Cause its simple implementation, but you always need to adhere to formatting and such which is absolutely useless knowledge

surreal girder
#

its thankfully very easy to import a model into blender, apply scale and export

humble hearth
chrome siren
#

does anyone have a solution for the laggy animation clip player?

chrome siren
drowsy flame
#

Reserved for Editor scripts, which add functionality to the Unity Editor at authoring time but aren’t available in Player builds at runtime.

Ok nice but does this mean that everything placed inside the Editor folder is not included in the final game build or just those scripts in there?

gusty mortar
surreal girder
#

I think thats wrong, it only puts scripts into an editor only assembly

#

assets in there work as normal

#

nvm it seems Resources is an exception, other assets will remain

primal shuttle
#

hopefully this is the right place to ask this, is there a way to get the editor to shift the text of the Hierarchy based on the size of its window? the left image shows how it currently works and i'm looking to get it to work like the image on the right

dealing with very limited screen real estate and would like to find ways to save space

#

just not sure why there is a big gap between the object type and the pick/visibility setting
maybe it is for when you have multiple Scene's but there is already a drop down and seperation between each scene and its objects so im not sure it makes sense

primal shuttle
#

realized i posted about this exact same thing in 2024, lol

#

need a "text wrapper" guess its still not possible

gusty mortar
opal ocean
surreal girder
#

One day unity will change object icons based on components without me needing a third party solution

opal ocean
surreal girder
opal ocean
#

thats why new new

#

its not in the new, so it might be in new new 😄

surreal girder
#

oh right my brain did not even notice the extra new

delicate coral
#

i can't add probuilder window to my toolbar - i drag and drop and nothing happens

dull geyser
#

im now creating the UI for this game, and i ahve a problem with the bottom part of the UI. i need it to be lower than the world (the white line across the screen)

glad needle
#

An error occurs when trying to view assets

surreal girder
#

modding cannot be discussed in this server

safe sorrel
#

good to know

surreal girder
# safe sorrel oh, that's neat!

It's strange because we can just load any asset in editor.
In the past I just automated deleting a certain folder to remove stuff from builds 😅

safe sorrel
#

i mostly just load editor-only resources by their GUID+FileID

queen wharf
#

I was under the impression ScriptableSingleton + serialized references was the ideal choice for this kinda thing, no?

safe sorrel
#

e.g. a custom property drawer

#

in that case, I use the GUID+FileID to load a visual tree asset, then instantiate and display it

#

I like that approach because it's completely immune to asset renaming and moving

#

I repeatedly footgunned myself by moving assets and forgetting that cared about the exact path to the asset somewhere

silk tree
#

For some reason resizing with scaling is causing these weird decimal placements even though the grid snap is set to 0.5

safe sorrel
#

totally unrelated, but how did you enable these measurements?

#

I turned them on once and could never figure out what I did

silk tree
#

The magnet thingy

#

and grid size

#

you can also hold shift or ctrl I think to move without snap

safe sorrel
#

i'm talking about the red/green/blue lines you see around the box

#

they're telling you how large its bounds are

queen shuttle
#

is there any api let me toggle the hand thing in code

#

SceneVisibilityManager.instance.DisableAllPicking();

#

nvm

elder wasp
#

Hello, my editor crashes randomly when I try to add items to an array through the inspector. I don't understand why and the error in the log looks like this. Any idea of what or why is this happening? Is this a known Unity Bug?

waxen sandal
#

If you have a custom editor, then you might be doing osmething weird, but if you don't, try updating unity

gentle badge
#

I am trying to get a List or Array of a custom class to show up in the inspector, anyone know what I need to do?

    [Serializable]
    private class EffectData
    {
        public string ReferenceName { get; set; }
        public float Value { get; set; }
    }

    [SerializeField] private EffectData[] effects;

I have this code but it shows up like this in the editor

#

I should probably mention the class is being defined in another class which the list is being displayed on

#

Nevermind ignore me, it can't serialize properties oops atwhatcost

elder wasp
elder wasp
glad needle
#

Does anyone know how to export asset bundles for older versions(2019.1) ? I've seen many tutorials but none of them worked for me.

opal burrow
#

was told this was the more appropriate channel-- did anyone know how to access all the possible values of binding.propertyName ? I have a script that copies and modiefies a bunch of keyframes, and I wanted to make sure that I get them all/ modify them appropriately..

#

all of them have the m_ prefix but i wasnt able to find a list of all of them in the documentation online

edit: i have for now resolved this by having a** default:** keyword in my switch... was impossible to search for everything, ill just bugfix if i ever encounter a binding that needs to be fixed

distant galleon
# elder wasp Hello, my editor crashes randomly when I try to add items to an array through th...

im sure its a bug that is solvable with the right research. so in the inspector. your trying to add items to an array? in c# we use Lists. they are our arrays. so your trying to add an item to a list from the inspector? so are you dragging and dropping an item into your list?

if you would copy and paste your console error i might be a better help.

i dont often work with logs but i read console errors on a nearly constant basis

#

if somehow a console error is not being logged but your getting a log. i wouldnt be your guy.l

distant galleon
# elder wasp Hello, my editor crashes randomly when I try to add items to an array through th...

from this log. what im gathering. is that you are trying to log into a database? maybe even if its unitys own user database. and you are failing at logging in. therefore youre logging in as a guest. some ids are getting assigned. a token is signed. probably a guest token. not a valid user token.

BatchMode: 0, IsHumanControllingUs: 1, StartBugReporterOnCrash: 1, Is64bit: 1, IsPro: 0

this line stands out a bit to me. what are the packages that youre using in your project? most likely the 1s are true and the 0s are false.

is this bug happening in your procedural terrain generator?

elder wasp
# distant galleon from this log. what im gathering. is that you are trying to log into a database?...

I see what you mean but it's far from the truth. From the first answer:
The items are manually created and destroyed from the list via code, the own holder of the lists manages it.
From the second answer:
I do not try to modify, log or enter any database. This is pure unity code unrelated to mine (at least from the logs side) It seems that the issue only happens on the LTS of 2021 and it's nowhere to be found on future versions, so it's probably something patched. I also followed all guidelines and it still was happening, so it's probably a patched unity bug that wasn't patched on older versions. Since there are now more unity versions (unity 6.3, unity 6.0 and 2022) that are considered supported by unity i decided to drop 2021 for now on the support for my asset

distant galleon
dusk dome
#

can you share data between custom editor windows?

real spindle
dusk dome
#

and can I programmatically open another window from one window?

real spindle
#

EditorWindow probably has some generic static method for that

#

I know there's EditorWindow.Getwindow

#

I think HasOpenInstances is what you want

#

I guess ScriptableSingleton can also be useful here?

#

If it needs to persist

dusk dome
#

I'll do some more research before I get into it

surreal girder
stiff coral
#

Hey, experienced web developer but beginner with Unity. Ive gone down a crazy rabbit hole of trying to write script to place some Prefab items in a grid.

Thats it, it all started with me messing with a tutorial that had me placing some cubes, then i just thought man its hard to get them equidistant, i would love to place them in a grid programmatically.....

Ive looking into Editor scripts but honestly i dont know if im going down the wrong path here, i just want to right click on a cube and run a custom script in editor mode with some arguments

dusk dome
surreal girder
#

Guess you can do that with imgui or uitk

#

or graph

dusk dome
surreal girder
#

Well with UITK you can use the visual editor to make editor gui

#

otherwise not really you just have to produce it using the pre made controls in either system (e.g button, toggle, text box)

#

but drawing some elements in a long row/column isnt hard

safe sorrel
#

UITK lets you define your own kinds of ui elements

#

which can be really useful when you're creating a ui for some specific task

bleak dagger
#

how to edit Dictionary in Inspector

real spindle
#

(Serialization is needed to show a type in the inspector and for it to be saved)

bleak dagger
#

thats why i posted in extensions

real spindle
glossy spoke
#

hey guys, im trying to install android build support for my unity editor on arch

#

and i get this error

#

which tells me nothing

#

im a bit stuck for what to do, i looked online and people said i might need to have cpio or p7zip, got both and still doesn't work

#

thinking of doing a manual install

#

anyone have any tips ?

surreal girder
#

!logs

dusty pineBOT
# surreal girder !logs
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

glossy spoke
tough cairn
# glossy spoke anyone have any tips ?

the UI looks new , im guessing its the latest version of unity hub ? Personally i try and avoid upgrading the Hub as late as possible due to crap like that. Maybe download older hub version from the archive ?

glossy spoke
#

i got a friend of mine to build the project

untold sail
#

is there any way to make a CustomEditor show on a heterogenous multiselection? i have a BaseClass, a bunch of Derived1 : BaseClass, Derived2 : BaseClass, ..., and a CustomEditor(BaseClass), and i'd like to be able to multiselect different DerivedX assets and have the inspector use my custom editor instead of showing "narrow the selection"

queen wharf
#

Is the [CanEditMultipleObjects] attribute not enough?

untold sail
#

unfortunately no, it only seems to work if the selection is homogenous

#

if i'm selecting different assets (even when derived from the same base class), the inspector forces this kind of view instead of rendering the custom editor defined for the base class, and this is even if i set editorForChildClasses: true on the CustomEditor attribute

queen wharf
#

whats the expected behaviour here?

real spindle
#

Combined with CanEditMultipleObjects

real spindle
#

Oh shit sorry just saw you mentioned it already 😅

untold sail
queen wharf
#

i could be tripping but im now realising i don't think unity would/does handle that

untold sail
#

i can of course make my own editor window for this, but it would be nice to have this integrated into the inspector

queen wharf
#

like if you normally multi select a mix of deriving inspectors it doesn't assumadly downcast right? with no custom editors involved

untold sail
#

yea it has the same behavior regardless of whether there's a customeditor or not

real spindle
#

Yeah just tested, apparently it doesn't support that

#

That's pretty annoying

untold sail
#

what i basically just want is to bypass the "narrow the selection" thing in this case, but i guess there's no api for that

real spindle
#

I would expect it to draw the fields that the classes have common from their base class but nope

queen wharf
#

i guess that makes sense tbh, i can think of some weird edge cases

full cedar
#

Ok, it actually seems that copying works via bind, but pasting doesn't.
Why?

stark geyser
#

@hearty shuttle Don't cross-post, your question is still visible where you posted it. If you want to post more complete question, update it.

hearty shuttle
rancid kraken
#

Has anybody had success using an IMGUIContainer to wrap a LocalizedStringPropertyDrawer? I'm trying to convert our editor tools UI to UIToolkit, and where Unity hasn't converted their drawers it seems like we have to use IMGUIContainers.

The problem I'm encountering is: editing a LocalizedString's local variables doesn't work when the drawer is embedded in an IMGUIContainer. I can add new local variables, but modifying or removing them in the UI does nothing. Not sure if the LocalizedStringPropertyDrawer isn't properly bound to the LocalizedString, or what.

#

We have an "aggregate" property drawer; basically just a drawer that embeds the native drawer for a property, and additional drawers for debugging info.

This previously used IMGUI:

        {
            AcquireChildDrawers();

            int drawerIndex = 0;
            foreach (PropertyDrawer childDrawer in m_childDrawerList)
            {
                Rect childRect = position;

                label = drawerIndex == 0 ? label : GUIContent.none;
                childRect.height = childDrawer.GetPropertyHeight(property, label); 
                childDrawer.OnGUI(childRect, property, label);

                position.y += childRect.height;
                position.height -= childRect.height;

                ++drawerIndex;
            }
        }```
#

converting it to UIToolkit...

        {
            Box container = new()
            {
                style =
                {
                    flexDirection = FlexDirection.Column,
                },
            };
            container.TrackPropertyValue(property);
            container.TrackSerializedObjectValue(property.serializedObject);

            AcquireChildDrawers();
            int drawerIndex = 0;
            foreach (PropertyDrawer childDrawer in m_childDrawerList)
            {
                // Prefer UIToolkit API for child elements, falling back to IMGUI when a child doesn't implement UIToolkit
                VisualElement? childElement = childDrawer.CreatePropertyGUI(property);
                if (childElement != null)
                {
                    container.Add(childElement);
                }
                else
                {
                    int index = drawerIndex;
                    
                    IMGUIContainer imguiContainer = new()
                    {
                    };
                    imguiContainer.TrackPropertyValue(property);
                    imguiContainer.TrackSerializedObjectValue(property.serializedObject);
                    
                    imguiContainer.onGUIHandler = () =>
                    {
                        GUIContent label = index == 0 ? new GUIContent(property.displayName) : GUIContent.none;
                        imguiContainer.style.minHeight = childDrawer.GetPropertyHeight(property, label);
                        Rect layout = imguiContainer.contentRect;
                        childDrawer.OnGUI(layout, property, label);
                    };
                    container.Add(imguiContainer);
                }

                ++drawerIndex;
            }

            return container;
        }```
rancid kraken
#

If anybody else cares, turns out I needed to call property.serializedObject.ApplyModifiedProperties(); at the end of the onGUIHandler

safe sorrel
#

ah, that'll do it :p

glad cliff
#

In package manifest manual and creating samples for pakcages manual I see conflicting information. In a former one it shows to include samples like "path": "Samples~/<sample-subfolder>", while the later one states Don’t append a trailing tilde (~). During the export process, Unity will rename the Samples folder to Samples~ automatically. This inconsistency makes me question the manual, so can anyone confirm that automatic tilde thing?

silk tree
#

Two in editor scripts to help with building!
How to install:

  1. Make an empty parent in your scene called "Services"
  2. Drag each script into the empty parent's components list.
  3. To disable just deactivate the scripts.

Information:
Both scripts have their own editable parameters inside the components list. To use the script once installed click any GameObject in your world and make sure view tool is selected to make it easier to grab the resize knobs/ place gapfill points.

Enjoy!

queen wharf
#

Generally people prefer editor tools that are actual editor tools and not components in scene

surreal girder
#

Yes it should be an editor window and not use a monobehaviour

hearty shuttle
safe sorrel
#

ah yeah, that's if you're using the "Export" button in the package manager

#

If you're using that workflow, then just name the folder "Samples"

#

If you're not using that workflow, you need to name the folder "Samples~"

glad cliff
#

Oh so thats the difference, OK then, thanks for clarification!

safe sorrel
#

however, since it won't be imported, you can't edit its contents while you're developing the package!

#

you can copy Assets/Samples over to Packages/com.coolpackage/Samples~ (that's what I do), but now you have two copies of everything in the project

glad cliff
#

Yeah I've been there as well last time I was making a package, didn't know about that automation then

opal burrow
#

how do i get my editor window floatField to have the click, drag to edit value functionalities? I saw some stuff about adding it in USS in chat history, or maybe changing it to a property field -- I wasn't able to get either to work but I'm also not really sure what I am doing

#

I also made my editor window without UI toolkit, so I don't know if that's bad either -- I thought that was a seperate thing that you could work with later on after you get the functionalities of the script done 😭

small galleon
#

hey so i just started a new project the other day, and for some reason my project settings arent saving. i noticed whenever i reopened the project my input system settings' actions are back at the default. sorry if this is the wrong channel

surreal girder
untold sail
#

is there a way to make a PropertyAttribute and custompropertydrawer in order to get a list/array to render "inline" in the inspector, meaning: no foldout, -1 indent level?

if i just create an attribute and apply it to a list field, it applies to the elements of the list and not the list itself

safe sorrel
#

see the "useForChildren" parameter

#

This was first introduced in 2023.1, so the last major version without support is 2022.3

#

annoyingly, this is the version that VRChat uses

#

I worked around this by creating a new DecoratedList class that wraps a list.

surreal girder
#

vr chat moment

untold sail
safe sorrel
surreal girder
safe sorrel
#

absolutely

surreal girder
#

so i guess some 6 version is their upper limit for an upgrade

safe sorrel
#

there is no god-damn way they're migrating off of BiRP for PC avatars

#

Quest avatars, at least, don't permit custom shaders

#

so they can just migrate

#

many PC shaders rely on GrabPass, notably, and I have no clue how they'd recreate that correctly

#

nevermind trying to migrate over a massive pile of compiled shaders

#

(they might upload the original shaders as well, at least)

surreal girder
#

Id deem that near impossible without some crazy work so I think it just wont happen ever

safe sorrel
#

i heard they tried to move to SPS-I (single-pass-shading, instanced)

#

but that didn't pan out

#

that only requires a bit of extra work to support in your shaders, but it was still too much

#

VRC uses double-wide rendering, which was nominally removed from 2022.3

surreal girder
#

Ah that is a big problem 😐

safe sorrel
#

they modify the shader compiler in some arcane way to bring back support for it

#

if this modification fails, you get some hilarious problems

#

your left eye is fine, but your right eye sees..

#

it's like you're seeing the left eye again, but it's all distorted

small galleon
surreal girder
near pumice
#

library\PackageCache\com.unity.render-pipelines.universal@e9f15c489688\Editor\Tools\Converters\ReadonlyMaterialConverter\ReadonlyMaterialConverter.cs(159,18): error CS0246: The type or namespace name 'MaterialReferenceChanger' could not be found (are you missing a using directive or an assembly reference?)

is this issue fixed? i checked many times no problem on my code.

#

Unity/URP package bug or broken package content issue

#

downgrade URP package or something?

safe sorrel
#

the global package cache, that is

#

if that is the cause, the fix would be:

  • Close Unity
  • Delete the Library folder from the project (this will force Unity to reinstall packages)
  • Delete the global cache folder, as described in that link (this will force Unity to re-download the packages)
#

i have seen this error more than once, which seems odd for something caused by completely random corruption

near pumice
#

yes done but keeps repeating @safe sorrel

#

now i am stuck for past 3 days

safe sorrel
#

did you do all of those things just now?

near pumice
#

can't fonish my tooling 95% done

#

yeah reinstalled got rid of c drive and all that fresh new project makes that issue

safe sorrel
#

"got rid of c drive" ...?

near pumice
#

have not tried using unity 6.4 though

#

i mean those cache

safe sorrel
#

ah, okay

#

what version of unity are you using right now?

near pumice
#

temp files that unity makes

#

6.3 lts latest

#

creating empty project makes that issue you know there's nothing inside just an urp template of a new project but it still gets like error you know

safe sorrel
#

right, because the problem is in the URP package's code

#

not in your own assets

near pumice
#

yeap 😄

safe sorrel
#

can you check the exact package versions you have in the Package Manager?

near pumice
#

well its opening will check soon

#

Yeah this issue has been reported by several users I don't know if it's fixed or not maybe I should try to use unity 6.4 but I started making the project using 6.3 not sure it's gonna work on 6.4 or not

safe sorrel
#

i see a handful of people talking about this

#

which is more than I'd expect for random cache corruption

near pumice
#

I think it has been caused by some recently unity update or something and I cannot finish my product right now that I was supposed to make for my client

#

Yes most likely I'm gonna miss this client I have to look for another client you know

#

going to try installing unity 6.4

safe sorrel
#

try navigating to this path, starting from the project root:

  • Library
  • PackageCache
  • com.unity.render-pipelines.universal@XXXXXXXXXXXX (the exact suffix depends on your package version)
  • Editor
  • Tools
  • Converters
  • ReadonlyMaterialConverter

Does this folder contain a file named ReadonlyMaterialConverter.MaterialReferenceChanger.cs?

near pumice
#

yea i have to delete this particular file to run unity atm

ReadonlyMaterialConverter.MaterialReferenceChanger.cs

#

after that it runs

#

it keep reappering after every new run btw

#

i hope unity fixes this issue

safe sorrel
#

...you're going to need to elaborate on that

#

are you deleting that file from your package cache?

near pumice
#

i am deleting in th eproject i make

safe sorrel
#

that's obviously going to cause a compile error, because you deleted a source file

#

this is some very important context you've left out

near pumice
#

and finished doing that steps u said before

#

if i keep this file i cannot press play: ReadonlyMaterialConverter.MaterialReferenceChanger.cs?

#

anyways its problem on unity end hopefully it gets fixed

#

i have no issues on my laptop

#

[CompilerError] The type or namespace name 'MaterialReferenceChanger' could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at Library\PackageCache\com.unity.render-pipelines.universal@e9f15c489688\Editor\Tools\Converters\ReadonlyMaterialConverter\ReadonlyMaterialConverter.cs:159 column 18

its a compilor error

safe sorrel
#

That error is caused by deleting that file

#

Don't do that

#

You are deleting the file that defines what a MaterialReferenceChanger is

near pumice
#

unity cannot complile currentyl fresh new projects start with that error

safe sorrel
#

where did you delete that file from?

near pumice
#

It's from newly fresh project

#

when i made another project but it s....it's a compiler error from unity When I made another project but it starts with that error anyways basically it's a compiler error from unity side

#

it has issues compiling urp package so most likely the package manager issue happening after updates

safe sorrel
#

I have no idea what you've done to your package cache at this point

#

I can't imagine how deleting the MaterialReferenceChanger script would fix a compile error about MaterialReferenceChanger not existing

near pumice
#

Thanks for your help trying to help me out uh I will see what I can I was hoping I could get some advice from here the experts you know

near pumice
#

i fixed it

#

but took 2 hours today and 2 more days on debuggin to seei f anything wrong on my end 😐

void violet
#

Hello ! Im working on an editor tool and I want to interview some devs to see if people generally think the things offered in it seem useful / valuable in a workflow .

Not trying to advertise or sell anything, I just want to get feedback on if this package actually seems like something that could be valuable for people, or if it's something you think people might use once and not pick up again.

Shoot me a DM !

gusty mortar
#

Hi ! Did anyone try out the new MainToolbarElement stuff from Unity 6.3 ? If someone did, is there something like a separator ? Didn't find anything in the documentation but there might be some secret knowledge 👀

dusk dome
#
private void ReplaceColors()
    {
        Debug.Log(ColorReplacementPairs.Count);
        if (ColorReplacementPairs.Count == 0) return;
        var text = TextureObjectField.value as Texture2D;
        newTexture = new Texture2D(text.width, text.height,  text.format, false);
        Graphics.CopyTexture(text, newTexture);
        var colors = newTexture.GetPixels();
        for (var index = 0; index < colors.Length; index++)
        {
            var col = colors[index];
            foreach (var cPP in ColorReplacementPairs)
            {
                if (col == cPP.ColorToReplace)
                {
                    colors[index] = cPP.ReplacementColor;
                    Debug.Log("COLOR HAS BEEN REPLACED!");
                }
            }
        }
        Debug.Log("color amount: " + colors.Length);
        newTexture.SetPixels(colors);
        newTexture.Apply();
        NewImage.style.backgroundImage = newTexture;
    }

I have this editor window that I'm trying to make where it replaces colours, but it doesnt seem to be actually applying the new colors. Am i doing this wrong? the debug log is firing

surreal girder
#

what is TextureObjectField ?

real spindle
# dusk dome ```cs private void ReplaceColors() { Debug.Log(ColorReplacementPairs...

Are you sure that Graphics.CopyTexture is doing what you want here?
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Graphics.CopyTexture.html

This method copies pixel data from one texture to another on the GPU. If Texture.isReadable is true for both src and dst, the method also attempts to copy pixel data on the CPU by running a CopyPixels method such as Texture2D.CopyPixels. If Texture.isReadable is false for either src or dst, or they are provided as type GraphicsTexture, no pixel data will be copied on the CPU and CopyTexture becomes one of the fastest ways to copy a texture. Warning: Be careful when using an Apply method such as Texture2D.Apply after CopyTexture, because you might copy old or undefined CPU texture data to the GPU.

dusk dome
dusk dome
surreal girder
#

All you did is modify it in memory and thats it

dusk dome
#

its meant to show the changes here, where modified uses the modified texture

surreal girder
#

Have you tried using a debugger to verify your colour matches work instead of debug logs?

surreal girder
#

vs code, vs and rider work

dusk dome
surreal girder
#

I remember there being a trick to modify any texture. May be that you can copy any to a new read/write texture

dusk dome
#

I have this colour field, and I want something to happen when the value changes. it does do this, but it also does it as I'm dragging around the little indicator. is there a way for it to only do it when you let go of the slider?

safe sorrel
#

is this UIToolkit or IMGUI?

real spindle
#

I assume that Apply was just overwriting everything that CopyTexture had done on the GPU

dusk dome
safe sorrel
#

I'm not aware of a way to do this -- there isn't a "commit" event.

I bet you could subclass ColorField to add support for that, though

glad pivot
#

i have my own managed reference instancer attribute drawer that we use, but for some reason when i have a list on a scriptable object thats using the attribute and i edit the list before a domain reload occurs. all the instanced references breaks. im kinda confused of why this happens. is it something with i have to just save before doing anything if not it wont store the references? it also only happens on the object that is drawn in the inspector while its reloading so maybe its someting with its being used while its reloading and it breaks?

glad pivot
#

Or could it be related to that i was editing the script which was being used in the managed reference and since it had its property drawer rendered it somehow messed with the reference?

opal burrow
bleak dagger
#

Is there way to set some extensions as default? Gets annoying to import all extensions, when starting project

mortal sundial
#

Can we drag & drop something from our own editor window into the scene? Kind of like you would drag a prefab in from the Project view.

wild edge
rapid relic
#

I'm trying to Change the inspector based on if the Event Type is set to Dialog or Move

but the Editor isn't doing anything
So I tested by making the Event Class a MonoBehaviour and It worked,
it was changed
but I don't want the Event Class to be a MonoBehaviour because then I can't use it in the Array like I am
Is there a way I could Change the inspector like this?
Or should I have the Editor interact with the Event Trigger script instead of the Event one?
if so how'd I go about doing that?

civic osprey
#

Hello! Is there a way for Rider to communicate with unity's localization table?

surreal delta
safe sorrel
#

a Custom Editor draws the entire inspector; a Property Drawer renders a single property!

opaque iron
#

in Graph Toolkit, one can dynamically add ports depending on value of an option easily. I somehow tried to execute the same on a Context Node where an Output Port becomes visible when there are no Block Nodes in it. The picture shows the behavior perfectly, however, changing stuff on the graph, like adding a Block Node to the middle one on the photo below doesn't remove the Output Port automatically.

#
class DialogueNode : ContextNode
{
    protected override void OnDefinePorts(IPortDefinitionContext context)
    {
        context.AddInputPort("Input").WithConnectorUI(PortConnectorUI.Arrowhead).Build();

        if (this.BlockCount == 0) {
            context.AddOutputPort("Output").WithConnectorUI(PortConnectorUI.Arrowhead).Build();
        }
    }
}

Am I lacking something or completely doing this wrong?

#

-# (example of what i didnt want to happen: context node's output stays available despite having a block node.)

opaque iron
#

nvm, i encountered more bugs like floating wire ends when doing what I wanted notlikethis

safe sorrel
opaque iron
#

at least in my setup

#

but yeah, completely ditched the idea of what i mentioned above

shy isle
#

!ide

dusty pineBOT
shy isle
#

bruh i thought it was to configure what editor you use 😭

#

now there's just the ide command in a serious and thoughtful conversation

thorny onyx
#

hey i couldn't really find a unity specific doc that explain how perlin noise works in rule tile the pattern is too not random

#

also how can implement this i made a rule tile for my room but i don't know how to implement a little passage for each room

brazen valley
#

What do you mean by passage?

#

And is this related to editor extensions?

idle tree
#

Is there any way to write code/tools that interface with the unity animator? I have tools and fixes I want to extend/fix/change its functionality to help automate some animation tasks

#

but most of what ive googled says Animator keyframes are untouchable

#

For example, I'd like to write a script that offsets all selected keyframes forward X frames, and then wrap/loops the stuff that went past the 'length' of the animation back around to the start, offset the whole animation's frame time

#

I can do the logic of that, but to do that I need some way to 'get' and 'edit' what keyframes are selected in Animator

safe sorrel
#

For editing the keyframes, you have to use AnimationUtility to read the existing curves in a clip

#

I am not sure about detecting which keyframes are selected.

#

You can get an AnimationWindow instance, but it only tells you a few things, like where the playhead is

#

The actual editing happens in AnimEdtior, and that's internal, so you'd need reflection to peek into it

prisma olive
#

Trying to install graph toolkit on unity 6.4 but "install package by technical name (com.unity.graphtoolkit)" results in "Unable to find the package with the specified name. Please check the name and try again.". Am i missing something here?

visual stag
prisma olive
#

which means what? I don't need to install it?

#

coz it doesn't show anywhere in the package manager

#

well i'll be damned... the assembly is there already. That's so misleading.

vast isle
#

how do i set icon for graph toolkit asset? do i have to use ScriptedImporter? i was hoping there is built in way to set icon

sleek chasm
#

Is there a way to override the skinnedmeshrenderer editor?

cosmic coral
#

Anyone know about GraphView? I'm trying to make right click pan the graph, cus I hate middle-click lol

#

But I can't get it working as context menu seems to completely consume right click, nothing else works under right click. Is there a way around this?

surreal delta
surreal delta
vast isle
cosmic coral
#

@vast isle @surreal delta
There are no changeable shortcuts for this? 2D Pan is only for scene view and is already assigned to right mouse

#

Also I've got more important issues now, I can't seem to override any of unity's controls. I want to not be able to delete the first node, however unity deletes it anyway.

Want to shift+click to add nodes to selection, but clicking another node single-selects it no matter what

#

Either graph view is not too flexible or i just can't figure out how to fully customize it

vast isle
#

have you tried RegisterCallbacksOnTarget with PointerDownEvent and PointerMoveEvent?

cosmic coral
#

Thanks

stark adder
vast isle
cyan karma
#

what does unit call this radio button style?

clear kite
cyan karma
#

I am trying to make something like this. This is what I can do, but I really wanted unity's because just look how beautiful and clean their version was compared to mine

opal burrow
#

^ am curious as well

clear kite
gloomy chasm
#

@cyan karma @opal burrow @clear kite That is a ToggleButtonGroup. But I highly recommend using Tab instead since it is made for it and follows the editor design guidelines.

opal burrow
#

im not using ui toolkit 😔 thought it was a thing that i could add on later to refine my ui, but couldnt figure out how to move my existing editor window script to it.

#

though, i didnt investigate too much since it wasnt pressing

glass hemlock
#

I'm trying to make a custom editor for my characters in-game diary/schedule, this is my first time doing custom editor stuff. Every time I close/open unity every schedule I've created with my custom editor seems to have vanished. For some reason, no changes I make to the list of schedules I create seems to be being saved?

The first screenshot shows the function in my custom editor script which calls to my my NPC info script

second screenshot shows the called function in the NPCInfo script (SerializedObject). "schedulesChapter" is a List of DefaultSchedules

third screenshot shows the layout of the DefaultSchedule (Struct)

forth is my custom editor with an empty timeline on launch

sorry if this is a bit convoluted, I just can't get any changes I make to the list to save through sessions, and I don't know why?

glass hemlock
#

this seems to have done it

untold sail
#

if i have a ScriptableObject that needs some additional import processing, what's the most efficient way to do that that would also be triggered if the code of the ScriptableObject changes?

#

i'm able to do the additional processing in OnPostProcessAllAssets successfully but it doesn't trigger if i modify the code of the scriptable object (for example to add a new serialized field)

#

i guess i just have to go through them all if didDomainReload=true?

shrewd shuttle
#

I'm learning unity editor stuff for a rhythm game project I'm working on at the moment to try and build developer tools for mapping. I've been looking around for any resources that would point me to being able to recreate unity's native audio visualization (like is done in timeline) and can't find anything. Can someone point me in the right direction for documentation?

visual stag
safe sorrel
#

Use Undo.RecordObject to track changes to the object

#

(SetDirty does also work; I believe that tells Unity to check if the corresponding C# object got modified)

#

You can also use the SerializedObject/SerializedProperty system to add the schedule item

#

this is generally more tedious, though

glass hemlock
safe sorrel
#

what object did you record?

glass hemlock
#

just (target) i believe

safe sorrel
#

specifically, you need to depend on the actual source file

real ivy
#

Hi all. Is it possible to rever the name of... a prefab in a prefab hierarchy?
In this case, it's this "Zone house" name. It's clearly bolded, but right clicking anywhere doesn't show the revert option. Going to debug mode also doesn't reveal anything relevant

surreal girder
real ivy
#

But is that technically "reverting" ?

#

Also, i call FindObjectsByType from an inspector button, in prefab mode. This gives these errors and the only Zone instance i'm trying to get it to cache (inside the hierarchy of the prefab itself) doesn't get added

surreal girder
#

If gameobject name is that important then your prefab + main component on it needs refactoring to use some other id

glass hemlock
#

I have an array of strings being represented by a propertyfield in unity's custom editor, does anyone know how to registercallbacks for it? I assume you'd need multiple different ones for adding/subtracting a list, and making changes to one?

surreal delta
safe sorrel
#

I am working on some handles. I'm having an issue where changing the length of the box causes jittering.

I presume this is because changing the length also changes where the center of the box is.

        var bakedSpotBox = target as BakedSpotBox;

        Handles.matrix = bakedSpotBox.transform.localToWorldMatrix;
        Vector3 center = Vector3.forward * bakedSpotBox.baseLight.range / 2;

        EditorGUI.BeginChangeCheck();
        
        Handles.color = Color.red;
        Vector3 newWidthPosition = Handles.Slider(Vector3.right * bakedSpotBox.width / 2 + center, Vector3.right, 1f, Handles.RectangleHandleCap, 0f);
        Handles.color = Color.green;
        Vector3 newHeightPosition = Handles.Slider(Vector3.up * bakedSpotBox.height / 2 + center, Vector3.up, 1f, Handles.RectangleHandleCap, 0f);
        Handles.color = Color.blue;
        Vector3 newRangePosition = Handles.Slider(Vector3.forward * bakedSpotBox.baseLight.range / 2 + center, Vector3.forward, 1f, Handles.RectangleHandleCap, 0f);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "Adjust Baked Spot Box");
            bakedSpotBox.width = newWidthPosition.x * 2;
            bakedSpotBox.height = newHeightPosition.y * 2;

            Undo.RecordObject(bakedSpotBox.baseLight, "Adjust Light");
            bakedSpotBox.baseLight.range = (newRangePosition.z - center.z) * 2;
        }
        
        center = Vector3.forward * bakedSpotBox.baseLight.range / 2;
        Handles.color = Color.white;
        Handles.DrawWireCube(center, new Vector3(bakedSpotBox.width, bakedSpotBox.height, bakedSpotBox.baseLight.range));
#

I understand that OnSceneGUI gets called multiple times per frame (since there are different event types, like "layout" and "repaint")

#

i feel like i'm incorrectly running the handles code when I shouldn't be

#

notably, if i move my mouse very slowly, i can make it flicker between a valid-looking result and an incorrect one

#

Ah, yeah, it was just an error in my logic

#

I needed to recalculate the center position before trying to subtract it from the current slider position

safe sorrel
#

I've noticed that my handles do not change color when I mouse over them

#

I'm having trouble figuring out how you actually do that

#

I've worked out that I can write a method that adjusts the color and then calls an existing handle function

#
        internal static void RectangleHandleCap(
            int controlID,
            Vector3 position,
            Quaternion rotation,
            float size,
            UnityEngine.EventType eventType)
        {
            if (eventType == EventType.Repaint)
            {
                if (HandleUtility.nearestControl == controlID)
                {
                    Handles.color = Color.white;
                }
            }
            Handles.RectangleHandleCap(controlID, position, rotation, size, eventType);
        }
#

e.g.

#

relatedly, this has made it a lot more clear how IMGUI works

#

the point is that you run the code multiple times (at least once to layout and once to paint)

#

as long as you consistently call the same functions in the same order, everything winds up with consistent IDs during each phase

brisk kiln
#

Hi,
I've got a question:

Since it's not possible to dynamically add or remove entries to a submenu of a [MenuItem], I was trying to use the GenericMenu and calling either ShowAsContext or DropDown on it.

Unfortunately, neither works as I'd like to:

  • ShowAsContext relies on Event.current to retrieve teh mouse position.
    -DropDown needs a rectangle to display the drop down menu.

For the latter, I have to get the mouse position myself, but I fail to do it in a convenient way which wouldn't rely on thinks like:

#if UNITY_EDITOR_WIN
if (GetCursorPos(out var point))
{
var pixelRect = new Rect(point.x, point.y, 1, 1);
return EditorGUIUtility.PixelsToPoints(pixelRect);
}
#ENDIF

And even then, while the x screen position is correct, the y position is offset.

Has anyone achieved to do what I want? If yes, how?

surreal delta
brisk kiln
# surreal delta You can make a MenuItem validation function and it will disable/enable said item...

Context why I need this: My tool allows opening the same window multiple times. In each window, you can select another schema to work with. On Mac, those windows might drop behind the actual Unity editor. I want to display a list of opened tool windows, so that the user can quickly switch to/bring to front the tool window he needs.

Unfortunatly, Unity does not allow this. So, I wanted to display a Context window or drop down list when the user clicks onto the "Show opened tool windows" menu point of my tool.

surreal delta
#

I think you are better off with a dropdown, you can customize the unity toolbar and add a dropdown of previously opened windows which you can dynamically change

brisk kiln
surreal delta
#

Why not add it to the toolbar?

brisk kiln
surreal delta
#

Thats perfectly fine, that dropdown can be enabled/disabled and moved around by the user, look at unity's dropdowns, there is one for quality levels, thats 1 button for 1 purpose

orchid mirage
#

hello, in ui toolkit, how to make an embedded list example like the left image?

surreal delta
#

You mean like removing the collection foldouts?

orchid mirage
#

Yes, the main purpose i would like to make a character team spawn editor extension function, but now I can't find a UI toolkit option similar to that

surreal delta
#

You just have to override the editor and instead of rendering the list you render a custom UI with the data in the list

brisk kiln
orchid mirage
#

Same like rpgmaker

orchid mirage
#

Alternatively, perhaps a UI toolkit feature is needed that allows for unlimited addition and removal of objects

#

Never mind i guess i have a solution, thank you

brisk kiln
tardy turret
#

What options do I have (even if paid) that is called not Odin to serialize an Interface to the inspector? Meaning I only want objects that implement a specific interface.

surreal girder
#

It's what I do anyway

safe sorrel
#

it can handle both Unity Object references and other classes

surreal girder
#

Sounds about right, serialize as something else and cast at runtime/on load

stray anchor
#

_Sorry, this is a repeat of my message in #💻┃code-beginner _
Hi guys! I'm really stuck with something. I think I'm missing something super simple, but I just can't seem to figure out what it is.

I'm currently working on customizing my inspector a bit, using VisualElements in a PropertyDrawer. Essentially, you have different QuestTypes, and depending on the QuestType I want to show different fields in the inspector.

I'm Adding the right children to the root, and it does work with the initial QuestType picked, but when I change QuestType in the inspector, no children get displayed even though my RegisterValueChangeCallback((changeEvent) => CheckForType()); gets called.

Again, it should be something so simple, yet I can't seem to figure out what I'm doing wrong. Anyone here have any experience with VisualElements?

#
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        objectiveType = property.FindPropertyRelative("type");
        PropertyField type = new(objectiveType);

        type.RegisterValueChangeCallback((changeEvent) => CheckForType());

        questObjectiveDetails = new PropertyField();
        VisualElement root = new();

        root.Add(type);
        root.Add(questObjectiveDetails);

        return root;
    }

    private void CheckForType()
    {
        QuestObjectiveType enumType = (QuestObjectiveType)objectiveType.enumValueIndex;
        questObjectiveDetails.Clear();
        switch (enumType)
        {
            case QuestObjectiveType.Collect:
                {
                    questObjectiveDetails.Add(new PropertyField(property.FindPropertyRelative("itemData")));
                    questObjectiveDetails.Add(new PropertyField(property.FindPropertyRelative("gatherAmount")));
                    break;
                }
            case QuestObjectiveType.Interact:
                {
                    questObjectiveDetails.Add(new PropertyField(property.FindPropertyRelative("interactable")));
                    break;
                }
        }
    }

is essentially what I currently have.

high gull
#

I've tried searching around but I cannot find anything, is there a way for me to add new elements to the play mode bar?

waxen sandal
stray anchor
#

I changed it, but doesn't seem to work either 🙃 I really appreciate the help though xx

#

It's like the Add isn't adding?? The Clear() works just fine.

waxen sandal
#

Uhhhh I very vaguely recall running into this at some point

stray anchor
#

Okokok, I'm gonna give that a try.

#

Thank yoouuu!

#

Hope this works hahah

high gull
#

Wonderful, thank you

stark geyser
stark geyser
#

This belongs in #🖼️┃2d-tools .
Also you need to click on the edit mode if you are editing tile palette.

vocal pivot
#

Oh, okay
Thanks

safe sorrel
#

i'm curious about the actual implications of this error getting spat out

One instance gets logged for each place that my prefab instance overrides a [SerializeReference] field.

#

The thing is that...it works fine?

#

notably: if I fully unpack the prefab, the resulting object has completely valid managed reference data

#

SSource<T> is derived from SerializableInterface<ISourceOf<T>>; it's just there to cut down on line length. SerializeableInterface works by storing a object with [SerializeReference]

#

Note that this is in 2022.3

#

I try to avoid overrides like this anyway (because they'll fall apart the moment I edit the parent prefab), so it isn't a very common situation

safe sorrel
glass hemlock
#

is there any way to track/trigger something when there's changes made within a class like this? the action I've set up tracks when I add/remove elements from the array but I can't seem to figure out how to get the script to recognise when I make a change to the "summaryy" or the "inkfilee". basically I want to set a callback for this which then applies the changes to the string or TextAsset to something else. thanks c:

surreal girder
glass hemlock
blazing ember
#

Is an Infinite Loop in the OnBeforeSerialize() normal when the editor window is open?

#

Only happens when I have the window with the actual property open

blazing ember
#

https://docs.unity3d.com/Manual/script-serialization-custom-serialization.html

I'm not really sure if I understand example: Directly serializing a Dictionary

I did exactly that, but I get 2 problems.
One, if I dont use MonoBehavior it works kinda but I get an infinite loop in the OnBeforeSerialize(). Making it very hard to set values.

Second, if I use MonoBehavior all i get in the inspector is a reference field

#

My Code:

using System.Collections.Generic;
using UnityEngine;

namespace UI.Converters {
    public class StringIntDictionary : MonoBehaviour, ISerializationCallbackReceiver {
        public Dictionary<string, int> MyDictionary = new();

        public List<string> Keys = new() { "ExampleKey" };

        public List<int> Values = new() { 42 };

        public void OnBeforeSerialize() {
            Debug.Log("Serializing StringIntDictionary...");

            if (MyDictionary != null) {
                Keys.Clear();
                Values.Clear();
                foreach (var kvp in MyDictionary) {
                    Keys.Add(kvp.Key);
                    Values.Add(kvp.Value);
                }
            }
        }


        public void OnAfterDeserialize() {
            Debug.Log("Deserializing StringIntDictionary...");
            MyDictionary = new Dictionary<string, int>();

            for (var i = 0; i != Mathf.Min(Keys.Count, Values.Count); i++) {
                MyDictionary.Add(Keys[i], Values[i]);
            }
        }
    }
}

And the Scriptable Object:

using System.Collections.Generic;
using UI.Converters;
using UnityEngine;

namespace _tmp {
    [CreateAssetMenu(fileName = "RanklistData", menuName = "Scriptable Objects/RanklistData")]
    public class RanklistData : ScriptableObject {
        [SerializeField]
        public StringIntDictionary PlayerScores;

        public List<int> TestNumbers = new();
    }
}
surreal girder
blazing ember
surreal girder
blazing ember
surreal girder
#

You want a serialisable class

#
[Serialisable]
public class DictionaryClass : ISerializationCallbackReceiver {
blazing ember
#

Okay I will do it this way thanks. Still have to figure out how to check what makes the asset being dirty. Maybe I should just look at a different example in general

surreal girder
blazing ember
surreal girder
blazing ember
surreal girder
blazing ember
real spindle
#

Unity calls OnBeforeSerialize on everything that needs to be drawn in the inspector, each frame repaint from my observation

#

It seems a bit weird, maybe it's just a quirk of the unity serialization system... I only noticed it by accident when I put a log in the method

surreal girder
#

Aha makes sense based on that stack

blazing ember
#

That would explain it if its the standard. The example given in the docu doesn't work for me because of that. cause at each frame it deletes the field values

surreal girder
blazing ember
#

Yea I will just add a flag probably. Thanks very much

real spindle
#

Seems like either the doc example has faulty logic or there's a bug with OnBeforeSerialize getting spam called from the inspector repaint

#

With OnAfterDeserialize never getting called

#

I'm starting to lean towards the inspector serialization bug

blazing ember
#

apparently its by design

real spindle
#

I guess the example in the doc just isn't supposed to be modified manually in the inspector

surreal girder
#

I wonder how odin solves this 😉

surreal delta
#

I do it like this @blazing ember

[Serializable]
    public class Map<TKey, TValue> : ISerializationCallbackReceiver, // Other dictionary interfaces
    {
        [DataTable]
        [SerializeField] private List<Pair<TKey, TValue>> backingField = new();

        private Dictionary<TKey, TValue> dictionary = new();

        void ISerializationCallbackReceiver.OnBeforeSerialize()
        {
            dictionary = new Dictionary<TKey, TValue>(backingField.Count);

            foreach (var pair in backingField)
                dictionary[pair.Key] = pair.Value;
        }

        void ISerializationCallbackReceiver.OnAfterDeserialize() { }

        public void Add(TKey key, TValue value)
        {
            dictionary.Add(key, value);
            ReinitializeList();
        }

        public bool Remove(TKey key)
        {
            if (dictionary.Remove(key))
            {
                ReinitializeList();
                return true;
            }

            return false;
        }

        public void Clear()
        {
            dictionary.Clear();
            ReinitializeList();
        }

        private void ReinitializeList()
        {
            backingField.Clear();

            foreach (var keyValuePair in dictionary)
                backingField.Add(new Pair<TKey, TValue>(keyValuePair.Key, keyValuePair.Value));
        }
}
queen wharf
surreal delta
#

You don't need two lists for the key and value, you can just create a generic serializable struct like my "Pair" one

surreal delta
surreal delta
#

as you can see in my example

glass hemlock
glass hemlock
# surreal girder try https://docs.unity3d.com/6000.4/Documentation/ScriptReference/DelayedAttribu...

afraid this hasn't helped at all :(

pic 1 is what currDialogues looks like as a custom editor propertyfield in the inspector
pic 2 is the class in the scriptableobject
pic 3 is what runs with OnValidate()

whenever I type anything into the summary text field, it flickers before being removed again. I experimented with making the OnValidate code running every 10 validates (basic int counter), and it only flickers the last character away every 10th validate, which of course isn't any good but it helps to know?

#

I would just settle for a one-frame coroutine, but annoyingly you can't call StartCoroutine in a scriptableobject

surreal girder
silent stratus
#

I'm using Unity's Behavior graph and I'm trying to use a Start On Event Message node to grab when the NPC's current goal has changed. I was struggling to get it to trigger with C# code so I tested it with a node where both nodes are using the same channel. It still never triggers though. Does anyone know why?

waxen sandal
silent stratus
#

I see, thank you

still tusk
#

can someone help me figure out why unity is reading my file errors but visual studio isnt?

still tusk
#

its also not autofilling

visual stag
#

!ide

dusty pineBOT
visual stag
#

@still tusk 👆

still tusk
#

I already tried regenerating project files

#

ive also tried restarting and reinstalling c# dev kit and other extensions

visual stag
still tusk
#

im repairing the NET sdk

#

hopefully it works

#

dang

#

it didnt work

light solstice
#

im trying to give custom icons to scriptable objects but the background isnt transparent, is there a fix?

#

i figured it out alg

scenic vortex
#

!code

dusty pineBOT
atomic sable
#

Is there no way to set a preview scene stage to be in 2D mode?

        protected override void OnFirstTimeOpenStageInSceneView(SceneView sceneView)
        {
            if (_instance != null)
            {
                Selection.activeObject = _instance;
                sceneView.in2DMode = true;
                sceneView.FrameSelected(false, true);
            }
        }

I tried using a delayed call, I tried using two delayed calls, i tried using EditorApplication.update to delay it multiple frames. It just.. won't work.

#

even if the main stage is in 2D mode, it will open in 3D

#

in fact when I debug log it it just isnt called even when restarting unity

#

ah nevermind... its because I'm not using this for an asset so I was returning string.Empty for the asset path and OnFirstTimeOpenStageInSceneView wasn't being called. Overriding GetHashForStateStorage fixed this.

rugged plover
#

hey all - ive built a tool for unity that i think would be useful for the community, and im thinking about releasing it for free. was curious if this was the place to discuss this? i just want to see if there's a generla interest in the community for it!

tropic mauve
#

@lilac valve was looking for a way to fix this Title bar and menus white even if its set to "dark mode" And came across this post https://issuetracker.unity3d.com/issues/the-title-and-menu-bar-are-white-when-editor-theme-is-set-to-dark
It is a old 2023 version but still "Resolution Note:
This has been the intended design for years. Closing as by design." Could you mby try to push this to someone who can revisit this? So we dont have to use 3rd part plugins. Its 2026 a whole app dark-mode should be eashy

#

Sorry if its the wrong channel

lilac valve
tropic mauve
#

Sorry most likly worded it a bit wrong. Just though you might know someone at unity who could pass it along.

gloomy chasm
lilac valve
#

I was gonna say a forum post on the Discussion page might help but maybe not. lol

gloomy chasm
tropic mauve
rugged plover
#

its a texture painting toolkit, mesh sculpting, texture painting, with some other features. i saw some available for purchase but none for free and figured i could release a good one for free that the community could use

gloomy chasm
rugged plover
#

if you wanna acheck it out, still working on it so its a wip

#

but so far things are working well

tropic mauve
#

not all version just do from The next version on?

rugged plover
#

feedback is welcome

#

any community input would be useful and credited if its a new feature or something

gloomy chasm
surreal girder
rugged plover
#

understood, good idea

#

im working on sculpting but its working fine, im optimizing because perfomance is dog at a certian point but its going well and if the community could use something like this i will for sure release it for free

#

its a lot more work than i anticipated initially

tropic mauve
rugged plover
#

but so far, you can use emissives, reflective materials, any mateiral works

#

i am really enjoying tool creation in unity so far though its sort of a weird hobby i picked up

surreal girder
tropic mauve
surreal girder
tropic mauve
#

i see why its not on by default

rugged plover
#

anyone want to test my tool i built if they have any environments able to be tested in?

#

jsut looking for general feedback on performance, high poly meshes would be nice to test on

#

its a texture painting tool, has sculpting functionality, etc

silver ingot
#

why doesn't probuilder have its own inspector in mine or some thing happened?

thick aurora
#

--------- ✂ ------------
I declare this channel OPEN!

visual mesa
#

I do love editor scripting! One-click builds, toggling different GameObject containers, various debug stuff, even uploading builds too

surreal quest
#

Both my assets are editor scripting, its also what i offer for commission work cause its what im decent at/enjoy

lone wing
#

Love editor scripting, my favorite here for a card game I am trying to make, sporadically . .

split mural
#

Haha, we also have a card editor too, except ours is really basic and it's used to set data for now

fresh yoke
#

was super simple to make, didn't take long, thanks to the simplicity of the tools

#

also discord breaks that gif 😄

#

it works expanded

split mural
#

Ah, I can see it fine, looks good @fresh yoke

fresh yoke
#

my motivation to do that was mainly because I once (a long time ago) needed to place some physics objects (ragdolls etc) into level and have them start at resting where they should be

#

nowadays Unity has that copy / paste values thing per object but back then only option was to simulate on play mode, make a prefab of new position and the after playmode, use the prefab instead

#

it was horribly convoluted workflow

#

like, for what it did

digital spoke
#

I'm trying to make a wall editor in unity where I can drag-create rooms like how you would in rpg maker (but in 3d) and I'm having a focus issue it seems

#

I force the editor window to have focus when I click the create button and don't unfocus until the player clicks it again

#

but even when I've clicked the button again to unfocus (and it does unfocus), I can't seem to drag select or click select in the scene view

#

I have to select manually via hierarchy

lone wing
#

@split mural nice 😃

digital spoke
#

I'm making mine a bit more simple

#

like that

lone wing
#

focus is kind of a pain, trying to remember how it is dealt with, hopefully somebody chimes in

#

that looks sweet

digital spoke
#

it does but the guy never went into basically any detail into how he made it lol

#

fixed it

lone wing
#

hah, nice, what did you do?

digital spoke
#
            HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

that was at the start of my OnSceneGui and I just moved it inside an if statement so it only ran while I was creating walls

lone wing
#

there's a utility for everything 😃

candid cipher
lone wing
#

that's cool

candid cipher
prisma chasm
#

solid thumbnail preview

nova scarab
#

So I have this code https://pastebin.com/azVwEKca. The goal was to draw a window background, then draw text on top of it. Only the first BeginGroup seems to be working, any ideas why?

visual stag
#

You might want GUILayout.BeginArea instead of GUI.BeginGroup

#

also you can use GUILayout.AreaScope and it might make your code nicer and force the EndArea call

nova scarab
#

It seems that GUILayout keeps the last rect position between groups

visual stag
#

How do you mean? Did you try using an Area?

nova scarab
#

Well the reason my pasted code doesn't "work" is because even though I'm calling BeginGroup setting the rect to 0,0,width,height Since the previous group filled out height, the next GUILayout.Label is trying to draw under the last GUILayout.Box call's rect.

#

Instead of over top of it

visual stag
#

@nova scarab this is why you need to use an Area because a GUI Group does not affect GUILayout content

nova scarab
#

If I use Area passing the same rect, it doesn't draw anything.

urban notch
#

Sorry i'm new ill put it in there

visual stag
#

Hopefully that gives you some general concepts. It's good to define the least amount of widths and heights as you can in GUILayout and let the layout handle the rest of it

#

with things like ExpandHeight you can ensure Styles that don't expand expand properly

#

You likely don't even need the calcsize stuff or any size definitions with the Output label

#

Additionally, it's kind of strange to have two overlapping areas like that. You can Style a scope and it draws behind the content

#

so I'd likely have a Horizontal scope to draw your two boxes and inside of that have two styled Vertical scopes instead of those boxes, and draw the Output label inside of the first Vertical scope if that makes sense

#

eg.

using (new GUILayout.AreaScope(new Rect(0, 0, 300, 300)))
{
    using (new GUILayout.HorizontalScope())
    {
        using (new GUILayout.VerticalScope("window"))
            GUILayout.Label("Output", EditorStyles.boldLabel);
        using (new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MinWidth(40), GUILayout.ExpandHeight(true))) { }
    }
}```
nova scarab
#

I see. I feel like it's very ambiguous and doesn't make a whole lot of sense.

#

Thanks for your time.

#

The code doesn't work for me, perhaps because I'm drawing it in a GUILayout.Window callback

visual stag
#

also there is a hidden debugger for GUI content if you want to have a peek behind the curtain

if (GUILayout.Button("GUI Debugger"))
    GetWindow(Type.GetType("UnityEditor.GUIViewDebuggerWindow,UnityEditor")).Show();```
#

it might show where things are rendering if you think they should be

#

@nova scarab are you surrounding your window calls in BeginWindows(); and EndWindows(); if this is editor code

nova scarab
#

Yeah

visual stag
void cedar
#

good to see people using the scope helpers 🙂

craggy sedge
#

When did those get added? Are they a replacement for BeginHorizontal and EndHorizontal etc?

visual stag
#

They've been there forever

craggy sedge
#

Ah looks like they came in 2018.1

#

Neat, I’m gonna have to start using those

visual stag
craggy sedge
#

Ah interesting, it doesn’t show up in the docs for 2017

visual stag
#

Every time I find an IDisposable I didn't know existed it is a god send

craggy sedge
#

That’s a good site, thanks for the link

#

Ha yeah it’ll make for much better looking code

lucid hedge
#

Yes editor scripting channel ❤

#

Here is a ladder graphic I did few days ago

#

Has anyone of you tried out the UIElements system?

void cedar
#

Begin/EndHorizontal are still there, but the scope versions are there to make it harder to skip the end due to mistakes/exceptions/etc.

visual stag
#

@lucid hedge yup, I'm using it all the time now. Slowly learning the Flex and CSS quirks

lucid hedge
#

Good to know

#

what do you like about it the most?

visual stag
#

easy borders, states, inline elements

#

it's just much easier to make complicated stuff

visual stag
#

I made something similar for a film pipeline I made that had like 6 interdependent packages and needed documentation and tutorials, so I built a hierarchical documention window for it. This is the next iteration of that, that's been entirely rewritten and has none of the inflexible hierarchy and instead behaves similar to a webpage, but allows button and content injection across pages

dapper wren
#

Hi all, are InstanceIDs of prefabs consistent between the Editor and Builds?

void cedar
#

I don't think instance ids are ever consistent across more than one session

dapper wren
#

That's a pity, I'm having that problem where a behaviour on a prefab is supposed to reference THAT prefab, but when you instantiate the prefab it instead of referencing the prefab it references itself. An attribute to prevent that would be great.

craggy sedge
#

Couldn't you GetComponent on the thing you're about to instantiate?

#

Or, after instantiating, pass a reference to the original prefab along to the script

true cove
#

the second one is what I usually do

#

but yeah it is kind of annoying that it changed the reference to itself 😛

wispy delta
#

I'm trying to create a menu item that gets a mesh from the active selection and generates some stuff based off of it. I want it to work on meshes in the scene and mesh assets in the project, but I'm not sure how to get the mesh from the mesh asset.

prisma chasm
#

what are you selecting in the assets in this context? an FBX or a prefab that points at the FBX?

wispy delta
#

fbx

#

I logged the object type of the selection when I had a mesh asset selected and it was a GameObject, which I found odd. I guess there's no reason to serialize mesh assets differently?

prisma chasm
#

this is the ideal editor function, you might not like it, but this is what peak performance looks like

        private static void DoMyThing()
        {
            GameObject temp = null;
            try
            {
                temp  = GameObject.Instantiate(Selection.activeObject as GameObject);
                MeshFilter mf = temp.GetComponentInChildren<MeshFilter>();
                Debug.LogError(mf.sharedMesh.vertexCount);
            }
            finally
            {
                if (temp != null)
                {
                    GameObject.DestroyImmediate(temp);
                }
            }            
        }
        ```
craggy sedge
#

If you're selecting the mesh itself in the project explorer, the imported asset is still the root GameObject, and not the mesh (the mesh is one of the imported 'sub' assets). Also, you can do a GetComponentInChildren<MeshFilter> on the asset GameObject directly, no need to instantiate (you may need to pass true as the second parameter, don't remember).

#

Another way:

// Get the selected object, forget if this is the one to use
GameObject selectedAsset = Selection.activeGameObject;

// Get the asset path for that asset
string assetPath = AssetDatabase.GetAssetPath(selectedAsset);

// Look through all the sub assets in the asset path
foreach (UnityEngine.Object subAsset in AssetDatabase.LoadAllAssetRepresentationsAtPath(assetPath))
{
    Mesh meshAsset = subAsset as Mesh;
    if (meshAsset != null)
    {
        // Found a mesh, do stuff
    }
}
prisma chasm
#

Nice

#

whats "true" in that get components call mean

craggy sedge
#

(I had to do something like this recently for an asset postprocessor)

#

It means "get the component even if it was inactive"

prisma chasm
#

ah inactive

#

let me try that

craggy sedge
#

I don't remember if that's necessary for assets

#

Since technically an asset game object doesn't exist in the world, it may be that they're always considered 'inactive' but I don't remember

prisma chasm
#

got it - yeah it was the "true" that was missing

#
        private static void DoMyThing()
        {
            GameObject go  = Selection.activeObject as GameObject;
            MeshFilter mf = go.GetComponentInChildren<MeshFilter>(true);
            Debug.LogError(mf.sharedMesh.vertexCount);
        }
        ```
#

works

craggy sedge
#

Nice - at this point I always put that in there, I'm not really sure why false is the default; can't think of any reason I'd want the Unity function to do that filtering for me

#

(unless it's just way faster or something)

prisma chasm
#

I actually hate the imported .fbx representation - feels really opaque and magical

craggy sedge
#

It is pretty annoying. The work I was doing related to it was to try to clean out everything inside except the animations, since we have some anims with blendshapes, and you can't import blendshape keyframes without having the actual blendshape in there

#

So we had dozens of FBX files, all with extra copies of head meshes and transform hierarchies, where all we want is the AnimationClip assets

#

So I wrote a postprocessor that kludgily deletes everything else after the import is finished

prisma chasm
#

our post processor does auto atlassing of models as they're imported. It's nice, but it sucks that the modified UVs only exist in the Library/ folder

craggy sedge
#

Yeah that's the other thing, once you start post processing assets like that there's no guarantee that all other team members will have the right representation unless they totally reimport everything

prisma chasm
#

yup

#

I wish there was a stage in the pipe where you could modify the mesh/hierarchy and save the revised canonical version

#

vs having it exist magically in Lib/

craggy sedge
#

The project view will show it correctly, there's just no difference from Unity's point of view between the unmodified and modified one

#

Since the library doesn't go in version control

#

It's not a huge problem as long as you get all your post processors out of the way early in development (or force everyone to do a Reimport All 😛 )

wispy delta
#

@craggy sedge @prisma chasm Thanks guys. I think I got it working now.

private static readonly string INVALID_SELECTION_ERROR = "Selection does not have a mesh.";

[MenuItem ("Tools/Deform/Create Vertex Cache")]
public static void CreateVertexCache ()
{
    var selection = (GameObject)Selection.activeObject;

    var target = new MeshTarget ();
    target.Initialize (selection);

    if (!target.HasMesh ())
    {
        Debug.LogError (INVALID_SELECTION_ERROR);
        return;
    }

    var mesh = target.GetMesh ();
    var cache = ScriptableObject.CreateInstance<VertexCache> ();
    cache.Initialize (mesh);

    AssetDatabase.CreateAsset (cache, string.Format ("Assets/{0}.asset", selection.name));

    Selection.activeObject = cache;
}

I made a struct called MeshTarget that basically checks a target gameobject for a MeshFilter or SkinnedMeshRenderer and abstracts access to it so that you can get a mesh without needing to know which component the object is using.

#

However now I'm running into a problem with scriptable object callbacks. The scriptable object, VertexCache holds a native array for vertices, normals, uvs etc. On a MonoBehaviour I'd dispose the arrays in OnDisable, but I can't seem to find a callback for when a ScriptableObject is destroyed.

I'm logging to the console when OnDisable and OnDestroy are called, but neither get invoked when I delete the scriptable object asset. OnDisable does get called when Unity recompiles which is good, but if OnDestroy and OnDisable aren't called when the asset is deleted I don't know what else would.

#

tldr: I don't think there's a callback on scriptable objects for when they get deleted

prisma chasm
#

hmm

#

you're deleting out of the project view

#

I don't think you get deletion callbacks in that context

craggy sedge
#

ScriptableObject is a bit different from MonoBehaviour in terms of messages, but it does have OnDestroy

prisma chasm
#

I don't think any of those get called for deletion of a prefab

craggy sedge
#

What happens if you delete it from project view, then go File > Save Project?

prisma chasm
craggy sedge
#

Yeah that might work more reliably

prisma chasm
#

second arg is anything that was deleted

craggy sedge
#

I think OnDestroy is only (generally) for ScriptableObjects you create at runtime, as copies of other ones

prisma chasm
#

^

craggy sedge
#

Although, it is weird that you would get nothing for destroying the assets

#

What's interesting is I'm pretty sure I use OnDisable a lot for Editors/EditorWindows

#

Which are scriptable objects

#

Though I guess those are more short-lived

wispy delta
#

Yea, that's funky. Well, thanks for pointing me in the right direction anyways

visual stag
#

hell if they could be remade to web controls that'd be the way I'd personally like to see it done

rigid kindle
#

Hey, bit of a stretch, but does anyone know of a way to load an external *.mdb into the editor? or of a way to force the editor to release locks on assemblies loaded by path?

#

If I load an assembly with Assembly.Load(path) unity will load the debug symbols, but will also lock the files until the editor is closed, If I use Assembly.Load(bytes) unity does not lock the file, but does not get debug symbols.

#

also, loading the pdb/mdb with Assembly.Load(assemblyBytes, symbolBytes) does not work either.

void cedar
#

hm, passing symbolBytes should work for an mdb

visual stag
#

does anyone know if you can modify UIElement styles associated with pseudo-states via code?

#

or what unityBackgroundImageTintColor is in USS?

void cedar
#

there should be unityBackgroundImageTintColor

visual stag
#

as in in a USS stylesheet - that seems to do nothing, as does -unity-background-image-tint-color which was my guess

void cedar
#

that should be it, for example:

    -unity-background-image-tint-color: rgb(137, 216, 255);
}```
visual stag
#

huh, it just doesn't accept transparent as a keyword, I assume I have to use none

#

nope, that does nothing either

#

I really wish stylesheets had error messages! The only way I've ever managed to get one is by copying your code because it must have a false-space character in there somewhere 😠

void cedar
#

oops, maybe it does

#

what about rgba(0, 0, 0, 0)

visual stag
#

huuuuh I think something else is happening in my specific case- sorry, and it's been working the whole time, this is extremely painful haha

#

to explain what I'm doing: the current light skin version of the ToolbarSearchField has busted hover and active states

#

so I'm trying to make them work properly

#

which involves setting a background image and tint

#

apparently I've now got the tint working - but the background image resources is finding is the dark skin image 😠

#

and I didn't even need the tint... gahhhh. Fixing fiddly things in UIElement is seemingly 100x harder than IMGUI

#

so then the question becomes how I would request skin-appropriate unity editor resources 😑 (as they seemingly have the same names)

visual stag
#

Sent a bug report for the incomplete ToolbarSearchField control Unity (Case 1117293)

#

it's literally taken me 5 hours to re-code what took me five minutes in IMGUI, and the styles are still broken 👻

odd spoke
#

Lol my face everytime shows up, can't remove previews in Discord? Anyway, it's not toolbar, but should be easy to change

fresh yoke
#

@odd spoke to remove preview just wrap your link between < >

odd spoke
#

thanks!

visual stag
#

@odd spoke I'm only interested in UIElement, and my search field already autocomplete searches across all of my relevant pages: https://github.com/vertxxyz/nDocumentation
I'm not interested in getting stuff done, only experiencing the most experimental and broken of APIs 🤣

minor marlin
#

I'm creating a list of objects which all derive from a base class, but when ever I recompile the code, all objects forget what they are and revert back to the parent class. Any idea how to stop this?

#

for example. the list is a list of commands and I have classes for a move command or attack command, but they all return to just baseCommand class

wispy delta
#

I'm trying to go through and refactor all my custom inspectors to use SerializedProperty so that I don't have to have a ton of gross code to allow editing multiple objects (ie: lots on LINQ on the targets array)

All of my components have private serialized fields and then public properties to abstract access to them. A lot of these properties do safety checks and clamping before setting the private field to value.

I'm not sure how to do this with SerializedProperty since tmk the control of the value is limited to the EditorGUILayout methods.

For example, I have a script that has a top and bottom float. I never want top to be less than bottom or bottom to be greater than top, but the only way I know to clamp the values is to use EditorGUILayout.Slider. In this context, a slider doesn't really work.

#

Slider wouldn't work here^

#

When I wasn't using SerializedProperties, I could just pass the GUI functions the property (c# property, not Serializedproperty) and it would work fine, but with SerializedProperty I have to recreate the safety checks used by the c# properties

#

The whole SerializedProperty thing seems very convenient, but if you have properties that don't directly get or set, you have to maintain those changes when modifying the backing field directly. I wish there was a better way.

visual stag
#

I'd likely make the PropertyDrawer use a Control that has that clamping behaviour

#

basically make your own serialized property control

#

which has that clamping behaviour

#

you can bypass the PropertyDrawer and just use the control if it's just a custom inspector in that case

wispy delta
#

Ok, I haven't done that before but it seems like a good middle ground. In the end I'll still technically be maintain two controls: the actual c# property, and the inspector property; which sucks, but I guess that's the best I can hope for.

visual stag
#

but you basically need to reimplement the logic, and can't really use the property logic with SerializedProperty

#

yeah, it's the middle ground I understand we deal with 😛

wispy delta
#

it be that way sometimes 😦 thanks for the pointer tho 😃

reef crane
#

If you only want to maintain one clamping method you could put the clamping behaviour in a public method, then have the property and the inspector access that. But it's adds a lot of extra code :/

#

But at least if you want to change the behaviour you don't risk having different behaviour and weird bugs as a result

wispy delta
#

Yea I was thinking about that as well, but I really don't want to sacrifice runtime code performance for editor cleanliness. If performance isn't an issue and you don't have too many properties, that's probably the most maintainable way to do it tho.

#

I ended up just creating two methods:

public static void ClampedMinFloatField (SerializedProperty value, SerializedProperty min, GUIContent content)
{
    EditorGUILayout.PropertyField (value, content);
    if (value.floatValue < min.floatValue)
        value.floatValue = min.floatValue;
}

public static void ClampedMaxFloatField (SerializedProperty value, SerializedProperty max, GUIContent content)
{
    EditorGUILayout.PropertyField (value);
    if (value.floatValue > max.floatValue)
        value.floatValue = max.floatValue;
}

Which lets me limit how low or high a serializedproperty can go based on another serializedproperty's float value. So now I can just do this:

DeformEditorGUI.ClampedMinFloatField (properties.Top, properties.Bottom, Content.Top);
DeformEditorGUI.ClampedMaxFloatField (properties.Bottom, properties.Top, Content.Bottom);
minor marlin
#

I'm having trouble keeping items in a list serialized through an assembly. The list is of a base class but populated with derived classes. I've found a method for keeping them using ScriptableObject on this page (Under General Array Serialization)

#

So I've made my base class a scriptableobject, but when i Create the Object that holds the list, the items are being listed as type missmatch and don't survive reload

brisk canopy
#

@minor marlin Unity's serialization doesn't support polymorphism, so derived classes will get turned into base ones, hence the need for that ScriptableObject workaround. I'm not familiar with it, but if you're getting type mismatch you might want to check the type of the list matches the objects you are adding to the list.

minor marlin
#

I'm copying the script as is and trying to implement it through creating a new instance of the SerializeMe Class and storing it on another scriptable object (using [SerializeField]), then loading it in a Editor Window. It just doesn't work though. Am I just implementing it wrong?

brisk canopy
#

@minor marlin I believe I may have replicated what you are doing - and I am also seeing the 'Type mismatch' shown in the editor window, however it does seem to be serializing the objects correctly after assembly reloads as long as you have the public void OnEnable() { hideFlags = HideFlags.HideAndDontSave; } part. It seems like it isn't showing them in the inspector correctly, as getting an object from the list and printing it is showing the correct types.

minor marlin
#

Cool, would you be kind enough to send me the project file please if possible?

brisk canopy
#

I'm just using the script straight from the link you posted (under the General Array part), as you are doing too. The only thing I have changed is the list's access from private to public so I could access it from a MonoBehaviour I added to the scene, and I saved the scriptableobject as an asset by using the below method. ``` [MenuItem("Assets/Create/SerializeMe")]
public static void CreateAsset ()
{
SerializeMe asset = ScriptableObject.CreateInstance<SerializeMe>();
AssetDatabase.CreateAsset(asset, "Assets/SerializeMe.asset");
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}

#

And the MonoBehaviour was just this, simply for testing purposes. All I did was drag the asset onto it and hit play, after un-playing the list references were still there, even if they did say the 'mismatch' thing I think it can just be ignored as they do seem to be serializing and can be accessed through code fine. ``` public class mono : MonoBehaviour
{
public SerializeMe serializeMe;

public void OnEnable(){

    MyBaseClass test = ScriptableObject.CreateInstance<MyBaseClass>();
    print(test);
    print(serializeMe.m_Instances);
    serializeMe.m_Instances.Add(test);
    print(serializeMe.m_Instances[0]);
    serializeMe.m_Instances.Add(ScriptableObject.CreateInstance<ChildClass>());
    print(serializeMe.m_Instances[1].GetType());
}

}```

minor marlin
#

My SerializeMe asset doesn't appear to work =(, has no data and can't be dropped onto the mono script

brisk canopy
#

Oh right, apologies - I also commented out the hideFlags = HideFlags.HideAndDontSave; line in the SerializeMe class

minor marlin
#

Yeah just did that, can see it now

#

getting a null error on print(serializeMe.m_Instances[1].GetType()); though

#

and on print(serializeMe.m_Instances[0]);

#

Oh nvm it's working now

#

I broke it by adding instanced before i pressed play

#

Thank you very much 😃

brisk canopy
#

No problem, I'm not that used to editor scripting like this so I'm glad I was able to help 😅

minor marlin
#

Doesn't appear to save after reloading the engine, all objects in list revert to baseClass. would that be a separate issue to serialisation or does it work for you?

#

To clarify by reloading I mean completely closing Unity and reopening it.

#

I'm looking into a video on how to save data to bytes anyway so hopefully this should be a better work around, that is if I can understand it >.<

brisk canopy
#

Yeah closing unity and reopening it does seem to be clearing the references. Hope the bytes thing works out better

wispy delta
#

Is there a way to add an item to the project's create asset menu that calls some method? I know there's the CreateAssetMenu attribute, but that is added to a class, not a method, and I want to do the asset creation myself. I'm looking for something with functionality similar to the MenuItem attribute, but for the project window.

#

Ideally I could also disable (grey-out) the button based on some method or callback that returns a bool

visual stag
#

Oh wait, project window? It should still work

#

The menus are literally the same ones I thought

#

I'll give it a test if you don't get to it first 😛

#

Yup, Csharp [MenuItem("Assets/Create/Hey")] static void Test() => Debug.Log("Hey"); gives me a sweet 💬 Hey

wispy delta
#

@visual stag Ah you're totally right -didn't know that, thanks!

grim monolith
#

@minor marlin You can add your scriptable object asset instance to your asset. Here's a quick example: Let's say that you have SO asset named Parent, then you create a new SO Child.

ScriptableObject child = CreateInstance<MyComponent>();
AssetDatabase.AddObjectToAsset(child, parent);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(child));
minor marlin
#

Thanks for that, I'll take a look tommorrow

grim monolith
#

This will make it attached like this and you won't lose your reference or mismatch it

#

Then finally if you don't want to see it you can use the HideFlags.HideInHierarchy so it's not visible, but it still exists

minor marlin
#

Thanks again 😃 looks interesting. Will have a proper look in the morning, Goodnight all

grim monolith
#

Np, if you have any question @me since I've been using this setup for a while for what you described above

minor marlin
#

Ok 😃

coral turtle
#

@grim monolith , do you have any good ways of handing cases where the added asset's script has been deleted? That happens for us some times, and there seems to be no way to delete the sub-asset. Usually you:

DestroyImmediate(subAsset, true);

But since it's script is deleted, you can't get a reference to it (LoadAllAssetsAtPath contains null instead of a reference)

We've usually either gone back in VC to restore the script, or just modified the .asset file manually, but I'm wondering if there's a better solution

visual stag
#

how about deleting a HideInInspector Component with a missing script 🤔 I had a test level with this broken in for... ever, it's still like it right now

#

you may have luck with the null object actually existing in a weird limbo of Unity Null, but in my case I was passed real null ):

grim monolith
#

@coral turtle Never tried that, so I'll play around with that and see if I find find any way to delete it.

zealous ice
#

Is there a way to expose array without exposing "array size" field?

vague portal
#

You would need to use a custom editor @zealous ice

zealous ice
#

I have this:

var allSettings = AssetDatabase.FindAssets($"t:{nameof(WaveEditorSettings)}");
if (allSettings.Length > 0 && allSettings[0] != null) {
                
} else {
    settings = WaveEditorSettings.Init();
    AssetDatabase.CreateAsset(settings, "Assets/Settings/WaveEditorSettings.asset");
    Debug.Log(AssetDatabase.GetAssetPath(settings));
}
#
settings = AssetDatabase.LoadAssetAtPath<WaveEditorSettings>(AssetDatabase.GUIDToAssetPath(allSettings[0]));
```Is this a good approach?
craggy sedge
#

If your path is always the same constant, I would skip the search and just directly do ```
var settings = AssetDatabase.LoadAssetAtPath<WaveEditorSettings>(your_constant_path);
if (settings == null)
{
settings = WaveEditorSettings.Init();
AssetDatabase.CreateAsset(settings, your_constant_path);
}

#

Though I think your approach is good in case a user moves the settings file somewhere

grim monolith
#

@coral turtle I think that is currently not possible, even Unity can't delete a non hidden object if the script reference is missing. At least version 2018.3.2f1 fails to delete the asset.

zealous ice
prisma chasm
#

are you saving the project between restarts?

zealous ice
#

Yes, of course

prisma chasm
#

just askin 😄

zealous ice
#

Looks like every point created in WaveEditorHandles.cs at line 55 is not serializable

grim monolith
gloomy chasm
#

Has anyone else been having a problem with custom property drawers in 2018?
They always error out for me. Even one that does nothing at all.

waxen sandal
#

What's the correct way to right align an element that scales to size?

#

Currently I have a Label - Flexible Space - Button however when I indent the Label it gets cut off slightly

#

Setting ExpandWidth to True on the label and removing the Flexible space on the Label makes the button right aligned but not scaled to size

visual stag
#

can you grab a screenshot of what you mean exactly? It'll just clear up a few details

waxen sandal
#

And this is with ExpandWidth on the text and without a flexible space

visual stag
#

so is Find X always a fixed size?

#

or do you have two unfixed sizes

waxen sandal
#

They're both unfixed in size

visual stag
#

I have ```CSharp
using (new EditorGUI.IndentLevelScope(1))
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField("Quite Long Text", GUILayout.MinWidth(0));
if (GUILayout.Button("Suspicious Stone"))
{

    }
}

}```

#

and it seems to have okay behaviour

#

set MinWidth of the first label to something more reasonable, I just made it 0 because it didn't collapse enough

#

I don't have your setup for differing text lengths but it should just... work?

waxen sandal
visual stag
#

oh, you want it to scale down to the content not just scale up, I see

#

could do something like:

GUIContent buttonLabel = new GUIContent("X");
Vector2 calcSize = ((GUIStyle) "button").CalcSize(buttonLabel);
if (GUILayout.Button(buttonLabel, GUILayout.Width(calcSize.x))) {}```
waxen sandal
#

Hmm, that might work. I'll have to try that later

keen oasis
#

This is my error

#

NullReferenceException: Object reference not set to an instance of an object
SA.CameraManager.HandleRotations (System.Single d, System.Single v, System.Single h, System.Single targetSpeed) (at Assets/Scripts/Camera Scripts/CameraManager.cs:93)
SA.CameraManager.Tick (System.Single d) (at Assets/Scripts/Camera Scripts/CameraManager.cs:59)
SA.InputHandler.Update () (at Assets/Scripts/Player Controller/InputHandler.cs:36)

#

_

#

and this is the line that it is highlighting

waxen sandal
#

Well something is null?

keen oasis
waxen sandal
#

pivot probably?

surreal quest
#

pivot is most certainly null

#

which means it doesnt have a value

keen oasis
#

I'll go check if that is the issue

#

yes, somehow it isn't displaying in the inspector anymore

keen oasis
#

I got my camera to work although it is still coming up with an error

#

NullReferenceException: Object reference not set to an instance of an object
SA.CameraManager.Init (UnityEngine.Transform t) (at Assets/Scripts/Camera Scripts/CameraManager.cs:37)
SA.InputHandler.Start () (at Assets/Scripts/Player Controller/InputHandler.cs:24)

#

which Highlights this line

surreal quest
#

Your camera probably isnt tagged as Main Camera

#

Camera.main every single time does a .FindByTag

keen oasis
#

yes I renamed it

zealous ice
#

I found a solution for my problem...

EditorUtility.SetDirty(settings.CurrentWave);
```that one single line
visual stag
#

Use the Undo or SerializedObject-SerializedProperty workflows to support undo and to dirty your object

zealous ice
#

I'll think about it

#

I can't use serialized property

zealous ice
#

Why EditorGUI.DrawRect(...); isn't showing everytime?

lucid hedge
#

Hey I'm having this very weird issue.

#

I'm using GUILayout.Toolbar

#

but the tabs are not linking up in edit mode

#

only in play mode

visual stag
#

I assume you are styling with miniButtonLeft, miniButtonMid and miniButtonRight?

#

Huh, I don't think I've used a toolbar before, you can always do it manually as I specified, sucks a bit though

lucid hedge
#

No I'm not doing any custom styles

#

ToolBarIndex = GUILayout.Toolbar(ToolBarIndex, menuOptions);

#

with menuOptions being a string[]

#

and ToolBarIndex just an int

#

and yeah I could style it manually

#

but in another tool of mine it works as it should

#

and I can't figure out what I'm doing wrong :p

visual stag
#

Well, without surrounding code I don't think I can help :P

lucid hedge
#

Yeah of course

#

Gonna try and experiment some more

#

because I do have a working version

#

I should be able to work this out :p

#

well

#

ToolBarIndex = GUILayout.Toolbar(ToolBarIndex, menuOptions, EditorStyles.miniButton);

#

just setting a guistyle seemed to fix it

#

ToolBarIndex = GUILayout.Toolbar(ToolBarIndex, menuOptions, new GUIStyle("LargeButton"));

#

looks even better

visual stag
#

I wonder what was making it bug out 🤷