#↕️┃editor-extensions

1 messages · Page 5 of 1

gloomy chasm
native geode
native geode
gloomy chasm
#

Or reflection

native geode
#

left it with validator and enable creation of item only on canvas 😁

shadow minnow
#

A few days ago i wrote a monobehaviour to draw a grid in my scene window using gizmos, but some of the scripts im referencing throw errors when im not in edit mode, and im unable to compile my game without commenting this out

#
public class RoomGrid : MonoBehaviour
{
    public Grid Grid;
    public Color GridColor;

    
    public void OnDrawGizmos()
    {
        Gizmos.color = GridColor;
        SceneView sceneView = SceneView.lastActiveSceneView;

        float x;
        float y;
        float xSize = Grid.cellSize.x;
        float ySize = Grid.cellSize.y;

        Vector2 origin = sceneView.camera.ViewportToWorldPoint(Vector3.zero);
        Vector2 extent = sceneView.camera.ViewportToWorldPoint(Vector3.one);

        origin.x = origin.x.FloorTo(416); origin.y = origin.y.FloorTo(240);
        extent.x = extent.x.CeilingTo(416); extent.y = extent.y.CeilingTo(240);

        int xCount = Mathf.CeilToInt((extent.x - origin.x) / xSize);
        int yCount = Mathf.CeilToInt((extent.y - origin.y) / ySize);

        
        for (var i = 0; i < xCount; i++)
        {
            x = i * xSize;
            Gizmos.DrawLine(new(origin.x + x, origin.y), new(origin.x + x, extent.y));
        }

        for (var i = 0; i < yCount; i++)
        {
            y = i * ySize;
            Gizmos.DrawLine(new(origin.x, origin.y + y), new(extent.x, origin.y + y));
        }
        
    }
}
#

i think that i need to turn this into an editor script, but im not really sure how to go about that

#

when it's an editor script, even though it's a monobehaviour im not able to attach it to a gameobject

#

i dont necessarily need the reference to the grid object, since the grid is always a fixed size anyway

#

i guess what im asking is, is there a way i can make an editor script update once per frame, like a monobehaviour?

#

and can i use an editor script to draw gizmos onto the screen?

#

if not, is there some alternative to this i could use

#

for what it's worth, the entire reason i even need this script in the first place is because the grid component in unity has it's own gizmo, but for some reason it's insanely dim and becomes downright invisible if i zoom out to the scale i actually need to work at

gloomy chasm
#

The quick and dirty way to do it is to surround your code in your class with #if UNITY_EDITOR so that the code will be excluded from build.

shadow minnow
#

looks like i cant use gizmos from this, is there some alternative ill need to use to draw the lines on my UI

#

switching to handles worked

#

Only issue now is that the grid only displays when an object of the given type is selected

#

is there a way i can make a custom editor display at all times? or when a child of an object of the given type is selected?

#

got it, found this

#

thanks for the help, i wouldn't have thought to use CustomEditors based on the name, lol

wraith raptor
#

Hi all, I'm looking for an editor to edit bezier curves like AnimationCurve does. Basically I want to open a graph window to edit 4 points of a bezier curve, is there any Editor component to do it? If not, what would be the approach to code something like this? Thanks

gloomy chasm
# wraith raptor Hi all, I'm looking for an editor to edit bezier curves like AnimationCurve does...

There is not. And there is no 'easy' way unfortunately. There are a bunch of ways you could go about it though.
If you are using IMGUI, you could use the Handles API to draw the curve (iirc that it works), and create some simple custom controls (using rects, get mouse down and see if it is in rect, if so than move it as the mouse moves).
Another options if you are using IMGUI, is to draw the curve with Graphics.DrawMesh.

If you are using UIToolkit, it has an API for drawing meshes which you can use to draw the curve. Or if you are on 2022.2 (iirc) they have a nice API for drawing curves. You would then just add some VisualElements with absolute positioning and register mouse down to drag them.

This is how the AnimationCurve window handles drawing for reference
https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Animation/AnimationWindow/CurveEditor.cs#L1023
https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Animation/AnimationWindow/ControlPointRenderer.cs

#

Hope that helps

dreamy dagger
#

Hi, hoping I could get an answer on this. Trying to create a context menu item on an array but need to know which array element was clicked (to act upon). Is this something that required custom editor?

gloomy chasm
wraith raptor
gloomy chasm
#

I am not really sure what you are doing currently without seeing the code.

dreamy dagger
gloomy chasm
#

You check if the path ends with ], that is how you know it is an array element

dreamy dagger
#

So inside this array element i have a property that i want to set..i can get the index out of this then? maybe i have to try this out first since not sure how this works. 🙂

stable crane
#

any idea why the texture goes past?

gloomy chasm
# stable crane

Because you set its y position to be the bottom of the properties height

stable crane
#

yeah but i add on its height in GetPropertyHeight?

gloomy chasm
#

I assume this is a property drawer?

stable crane
#

position starts from top left doesnt it?

#

yes it is

gloomy chasm
#

You want textureRect.y = position.yMax - PREVIEW_HEIGHT;

#

EditorGUI.GetPropertyHeight(..) returns the height that you are returning from your override float GetPropertyHeight(..) {}

stable crane
#

ohh

#

makes snse

gloomy chasm
#

Also is redundant because position.height will be that height already

stable crane
#

no but now it doesnt work

#

well

#

it hides all the other fields

gloomy chasm
#

Can't do much without seeing the code

stable crane
#

i tried textureRect.y = rather than += too but thats what gives me the issue i just said btw

gloomy chasm
#

What does it look like in inspector?

stable crane
#

oh ive solved it now

#

in GetPropertyHeight i used EditorGUI.GetPropertyHeight rather than base.GetPropertyHeight

gloomy chasm
#

What? In the code yo are showing you use base....?

stable crane
#

yeah

#

i changed it to EditorGUI

#

and that fixed it

#

sorry i worded it weirdlyt

gloomy chasm
#

Oh

#

oooh yeah because base defaults to a single line height

dreamy dagger
quick crypt
wraith raptor
#

Btw, thanks @gloomy chasm

normal ocean
# stable crane

May i know which font and theme u are using?
It looks good

stable crane
#

font is Iosevka semibold, theme im not sure i think its called bearded something in the vs code extensions

pine gale
#

Is there an existing unity editor extension for code editing on the asset store? Looking for things like code search and template files for ScriptableObject, interfaces, JSON files, and other common Unity/C# constructs. If not, would people be interested in using an extension like this? What features would people want to see?

gloomy chasm
pine gale
flint garnet
#

im still on the way learning UI Toolkit for editor, and i found USS way better to styling my Editor GUI, compare to using GUI Style, like simply changing background color, any way, my question is, i did see before there is .FromUSS, and assume from the name, maybe i can use USS in unity editor scripting using IMGUI, but i can't find that again, anyone know about that (.FromUSS)

waxen sandal
#

Looks like it just maps some specific properties to the GUIStyle

#

Definitely not a complete mapping

#

(besides, it's missing all flexbox things from parent containers)

flint garnet
#

i will take a look, thx

night totem
#

how to remove these elements in visual code 2022?

night totem
waxen sandal
#

Idk go ask visual studio code people

patent venture
#

Why do you want to remove them?

stable crane
night totem
night totem
stable crane
#

get it then

night totem
stable crane
#

google and click download

night totem
#

how to turn it off?

night totem
#

How to disable it in the rider?

gloomy chasm
# night totem How to disable it in the rider?

This is not related to creating editor extensions, or unity. I recommend looking up the documentation for Rider, and asking on their forums (if they have one) or contacting their support if you still can't figure it out. However it does not belong being asked here. Best of luck!

hollow rampart
#

Is it possible to add webview on editor?

waxen sandal
#

I don't think there's anything built in

hollow rampart
#

embed chrome?

waxen sandal
#

I haven't really investigated it, there's probably a bunch of resources online with info

#

But it's probably not simple

gloomy chasm
#

I don't think so no.

#

If you want to share what you are doing there might be another way to do it?

thorny rock
#
public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        serializedObject.Update();
            
        // ScriptableObject
        SerializedProperty guardVisionSO = serializedObject.FindProperty("_GuardVision");

        // SphereCollider child
        SphereCollider sphereCollider = Selection.activeTransform.GetComponentInChildren<SphereCollider>();
        var sphereColliderSO = new SerializedObject(sphereCollider);
        sphereColliderSO.FindProperty("m_Radius").floatValue = scriptableObjectReference.radius;
    }

I'm trying to read the data of a ScriptableObject and pass it to a collider that sits on a child-gameObject. In this case my SO tells my collider how big it is (how big the vision radius is).

So basically the question boils down to: What is the proper way to get access to the variables in a ScriptableObject via an editor script?

#
var guardVisionSO = serializedObject.FindProperty("_GuardVision").objectReferenceValue as GuardVision;
sphereColliderSO.FindProperty("m_Radius").floatValue = guardVisionSO.Length;
sphereColliderSO.ApplyModifiedProperties();

This works.

regal forum
#

Hi. Is GUI.Box immutable?
I did this for my custom editor for Inspector:

GUI.Box(
  dropArea, // this is "Rect"
  evt.type == EventType.DragUpdated ? BOX_RELEASEHERE : BOX_DROPHERE, 
  GetStyle(GUI.skin.box));
```But my Box is displaying only the text of `BOX_DROPHERE`, even when i drag an object over the `dropArea`.
How do i update the text to change when i'm holding an object over the Rect area?
Is it impossible? 

> I read all the related classes on the scripting API, even removed the GuiStyle, tried to use `GUIContent` to see if the reference would update the text, but nothing is changing the text after the first time it draw the call _(i think)_.
gloomy chasm
regal forum
tawdry kraken
#

Hey. I'm trying to animate a radioButton selection, like with AnimBool and EditorGUILayout.ToggleLeft().
Haven't found anything on google. Anyone know a way?

waxen sandal
true crow
#

hi all, is there like a brush tool in unity to make plains in a 3d project

gloomy chasm
tawdry kraken
#

I'm making an EditorWindow, and am trying to use EditorGUIUtility.PingObject() on an asset, after is has been imported.
I have not been able to find a suitable CallBackFunction for this scenario.
The pinging itself works fine if I re-ping it manually after the automatic process.
My attempts to poll for this scenario have failed, lastly using a bool and EditorApplication.isUpdating

It could probably work if I wait 1 second after isUpdating was last true. But I'm not sure how I could make a timer for an EditorWindow, and I don't think a Coroutine is a good idea for an Editor script.

Any ideas?

waxen sandal
#

EditorCoroutines are a thing

#

And have you tried delayCall?

tawdry kraken
# waxen sandal And have you tried delayCall?

I have not, but by its description I don't think it will help much.
When the button is clicked, one or more .png files are generated, which cannot be pinged until the editor has had ample time to process them.
My solution waits until the last item has been processed, and then pings it.

#

But right now it executes too soon.
I will look into EditorCoroutines.
Though I did just find that using OnInspectorUpdate and EditorApplication.realTimeSinceStartup gives me a working counter inside OnGUI

tawdry kraken
#

delayCall did not work.

waxen sandal
#

It's hard to say without seeing some code what's going on really

#

Guessing it's not done importing?

tawdry kraken
# waxen sandal It's hard to say without seeing some code what's going on really

Pardon the late reply. I've been hard at work.
I was eventually successful in implementing a time-delay which did ping the newly created asset.
At that point, I started stripping away stuff to see if there was less required.
And it seems I have had a case of an Empty string; it was being initialized at the wrong time, and a / too many.

Now it all works without the delay.

#

directly inside OnGUI
(PS: For anyone researching. The example in screenshot has one error - Refresh() needs to be moved two lines up.)

waxen sandal
#

Glad you got it working!

stoic heart
#

Are EditorTools not allowed to draw interactive handles?

#

nvm you just put it into onToolGui, though that's not specified by the hint

wary jungle
#

Anyone know if there are extensions for VS Code that will do the following?

  1. Make curly brackets drop a line when created.

//Like This
if(Test)
{

}

//Not Like this
if(Test){

}
  1. Be a bit smarter about auto-completing.... for example VS would know that I want "GetComponent<Animator>()" the second I typed = g whereas VS Code is like "For this animator you want to get!!!!! ??? Get what you tell me!!" 😂
stable crane
#

and for 2) it sounds like you dont have the unity stuff properly configured

stable crane
#

is it broken just for me or do packages like
https://github.com/SeaeeesSan/SimpleFolderIcon
or
https://github.com/WooshiiDev/Unity-Folder-Icons
not work anymore?

GitHub

Customize the folder icon in Unity project window. Contribute to SeaeeesSan/SimpleFolderIcon development by creating an account on GitHub.

GitHub

Lightweight Unity Utility adding coloured folders and icons to your project window - GitHub - WooshiiDev/Unity-Folder-Icons: Lightweight Unity Utility adding coloured folders and icons to your proj...

stable crane
#

ok ive got them to work by modifying them a little bit

#

not sure why but projectWindowItemOnGUI doesnt get invoked

#

but projectWindowItemInstanceOnGUI does

#

so i just changed it to that and used AssetDatabase.TryGetGUIDAndLocalFileIdentifier(instanceID, out string guid, out long _);

#

to get guid from instanceid

wary jungle
stable crane
#

@pure quartz sorry for ping first mod i saw

pure quartz
#

thx!

tardy pecan
#

Any way to change the title bar of a component? I just want to modify the text according to some variable

stark yoke
tardy pecan
#

Yes but I'm looking to change it based on properties from the component. If I have 3 of the same component to a game object, it makes it hard to identify which one is doing what

#

If I have something like this, I'd like to set the title to VoidEvent (name of the event property)

#

I know there's a plugin on the asset store that does this, so it must be feasible

stark yoke
tardy pecan
#

Not with the way my system works no

stark yoke
tardy pecan
#

Thanks! I've seen a few threads saying that you can but yeah it's not explained

#

Update: Looks like this is the private property to set via reflection in the editor

#

Doesn't seem to allow me to set it using set value

stark yoke
#

And I'm pretty sure I can find a solution to your problem if I spend more time on it

stark yoke
#

Plus I need to see at least a bit of your code

#

To see if there's a way of having one script instead of two

tardy pecan
#

Yeah the CanWrite flag of this property is set to false

stark yoke
#

Three*

tardy pecan
#

There's no way of having one script, it's a generic system so I can have 5 events or 100, also I have more types of events like int, booleans, etc...

#

I mean technically I can have an array of events for each type but it's definitely not as convenient and clean

#

Here's the code if you want to take a look tho

stark yoke
tardy pecan
#

Even then I would have to open the thing and find the right event

stark yoke
tardy pecan
#

Oh well looking at it is not gonna help on this just sharing haha this is the event system I'm working on

#

The issue I have doesn't have anything to do with my code specifically it's more a general question

stark yoke
tardy pecan
#

Thanks so much! I'll update here if I can find anything because damn I can't be the only one looking for this lol

gloomy chasm
#

Setting the monoBehaviour.name to something should change it I think

tardy pecan
#

When I call the name thing on the target object it usually refers to the GameObject name, are you talking about a property that I need to access through reflection?

barren moat
#

Is it possible to draw a property drawer for a generic type?

waxen sandal
#

Explorer?

blissful burrow
#

does anyone know how to detect right click on a Handles.Disc() in the scene view?

#

I feel like I'm getting lost in hotControls and IDs and no events seem to line up ;-;

blissful burrow
#

okay I got it, but man,, ahha, I'm guessing there's an easier way to do this?

// oh boy this is a hack
int discID = GUIUtility.GetControlID( "DiscHash".GetHashCode(), FocusType.Passive ) + 1;
Quaternion qNew = Handles.Disc( q, pos, axis, handleSize, false, 0 );
EventType discEventType = Event.current.GetTypeForControl( discID );
if( HandleUtility.nearestControl == discID && discEventType == EventType.MouseDown && Event.current.button == 1 ) {
    Debug.Log( "RMB on disc " + discID );
    Event.current.Use();
}```
blissful burrow
#

alright, this works for one handle, but I can't get it to work for something with multiple handles, eg Handles.RotationHandle

#

tried porting over all the handle IDs but only the first ID is responding

waxen sandal
#

Have you looked at the source for how unity handles rotation controls internally?

gloomy chasm
pine gale
#

Has anyone else run into an issue in Unity 2023.1.0a16 with undo/redo selection in a custom graph view? I can restore most selections, but when I deselect all elements, it adds an undo entry which selects the last selected elements, instead of deselecting all elements. I have almost no code in this GraphView - I just create the elements by loading it from a ScriptableObject, I've disabled all code to sync the changes from the GraphView to the ScriptableObjects. Anyone seen this before? Maybe a bug in 2023.1.0a16? Attached a recording.

blissful burrow
blissful burrow
blissful burrow
#

the +1 in my code

#

it's a hack to get the next generated ID

#

when the handle kicks in

gloomy chasm
#

wait, why are you trying to get the next generated ID?

blissful burrow
#

I don't know how else to get the handle IDs of those functions

#

as in, handles.disc and the multiple handles in RotationHandle

gloomy chasm
#

Yeah I don't get what you are wanting. You wanted to get right click on a handles disc, yes? So you figure out. Now you want to get right click on a sub-handle from RotationHandle?

vapid prism
#

0

barren moat
#

wrote the wrong word

#

I got my thing working sufficiently

robust plume
# barren moat Is it possible to draw a property drawer for a generic type?

It's possible, but you might have issues in specific cases.
Like, you can have a base editor/inspector, and then a derived version of that same editor for any derived types of your base generic class.

But if you try to put these into a reorderable list in the inspector, you'll run into issues it seems. Unless this is fixed in 2022

#

At least when using visual elements

gloomy chasm
robust plume
#

Am I allowed to post .cs files to reproduce an error I'm getting?

visual stag
robust plume
#

Ok, so I'm having this problem with generic lists and custom property drawers using the UIElements library.
When I reorder items in the list that are of different types, it causes the errors to show up like:

SerializedProperty items.Array.data[2].value has disappeared!
type is not a supported float value
UnityEditor.RetainedMode:UpdateSchedulers ()

This also happens in a more complicated custom editor I have when I delete an element and a differently typed one takes it's place, but that behavior doesn't seem to show up in this basic example.

Version of Unity is 2021.3.2f1
Code for reproducing: https://paste.ofcode.org/yFDGtMp4TYzTEcvN5J2jwi

waxen sandal
#

Try IMGUI instead? I've done something similar in IMGUI and that worked before

#

So would be good to see if it's a regression or bug in UITK

#

Could also be caching of your propertydrawer and the element in the list

#

Aka, it assumed it can reuse the element and jsut rebind but it can't since they're different types

#

Guessing it's the latter tbh

barren moat
barren moat
#

ah no I only tried that for custom inspector. Alright I'll give that whirl.

waxen sandal
#

Probably have to pass true as second parameter for derived types

robust plume
robust plume
#

It's annoying because it seems like it does fix itself after it actually updates.

robust plume
agile badger
#

Anyone know how I could get an event when the user attempts to close my custom editor window, and ask them if they want to exit without saving changes?

#

I wanna make sure that they can cancel the close request if they did it by accident without saving

waxen sandal
#

I think you can use EditorUtility.ShowDialog

#

But you can't cancel the close

#

in OnDestroy

agile badger
#

Could I possibly just have it re-open the editor window and restore the state of the destroyed one?

#

Surely there's a way to do this because I know the Input Actions editor does this type of thing?

waxen sandal
#

Well, packages are open source so take a look

agile badger
waxen sandal
#

Not sure which window you mean but it should be in there

agile badger
agile badger
#

Bit hacky but yes

shell beacon
#

Guys, is there a better way to open this shortcuts window from my editor script?
Because it's "inaccessible due to its protection level" I tried something like this using reflections

    EditorWindow.GetWindow(typeof(Editor).Assembly.GetType("UnityEditor.ShortcutManagement.ShortcutManagerWindow")).Show();```
Which works, but I don't like it 😛
waxen sandal
#

ExecuteMenuItem

shell beacon
waxen sandal
#

Neither is really better tbh 😛

shell beacon
#

lol yea it's subject to changes

#

It's way more elegant tho 🙂

#

Another question, is it possible to go to a specific category in this window (if it's already open or not)?

waxen sandal
#

Probably with more reflection

#

Would have to go dig through the source though

shell beacon
#

Yea what I thought lol

#

I think I'll keep it simple

#

Thanks 🙂

alpine bolt
#

Is it possible to override CTRL+D for certain Scriptable Objects selected in project view? Or any shortcut related with asset manipulation.
I have this duplicate method that deep copies a SO and its content, but if I duplicate via CTRL+D in project, it will make a shallow copy

waxen sandal
#

Not really afaik, I guess you could try to detect it using import callbacks

#

And use Selection.ActiveObjects

near wigeon
#

I'm trying to set the initial assetimporter properties of a newly created asset, but unfortunately it's not taking. I think the reason is because the meta file which stores the import settings has not been generated yet. Do I need to create the asset, refresh the asset database, and then reimport with my initial properties? Or is there some hidden API to do what I'm trying to do?

waxen sandal
#

Show code

near wigeon
#

my plan is to store the import settings in the asset when I create it, read them in a asset preprocess, and apply them to the importer if there is no meta file

#

hmm there is a lot of code noise. will take a second to distill

#
//create the asset
  var asset = ScriptableObject.CreateInstance<MyCustomAsset>();
  string path = AssetDatabase.GenerateUniqueAssetPath("some/path/NewCustomAsset.custom");
  AssetDatabase.CreateAsset(asset, path);
  AssetDatabase.SaveAssets();
  AssetDatabase.Refresh();
//set the asset import settings to initial values
  MyCustomAssetImporter assetImporter = AssetImporter.GetAtPath(path) as MyCustomAssetImporter;
  assetImporter.setting1 = "..."; 
  assetImporter.setting2 = "..."; 
  assetImporter.setting3 = "...";
  assetImporter.SaveAndReimport();
#

of course, this doesn't work as the meta file doesn't exist when I try to set the initial import settings, so thinking I have to store the data on the scriptable object itself

alpine bolt
#
        void OnValidate()
        {
            Event e = Event.current;
            if (e?.type == EventType.Used)
                if (e.commandName == "Duplicate")
                    // HANDLE DUPLICATION
        }``` this seems to work
visual stag
mossy wren
#

I think visual studio doesn't understand if there is a solution or something

near wigeon
#

Part of the problem that I failed to articulate is that all assets have different initial import settings (different source assets) that are defined by the asset creation script.

#

What I ended up doing was writing all this out to the asset file itself and then read it on import if there is no import settings yet.

#
public override void OnImportAsset(AssetImportContext ctx)
{
  if (importSettingsMissing)
  {
    MyCustomAsset myCustomAsset;
    using (var reader = new StreamReader(ctx.assetPath))
    {
      myCustomAsset = JsonUtility.FromJson<MyCustomAsset>(reader.ReadToEnd());
    }
    setting1 = myCustomAsset.setting1;
    setting2 = myCustomAsset.setting2;
    setting3 = myCustomAsset.setting3;
    ...
  }
  ...
}
short tiger
#

I have a custom ScriptedImporter that I'm trying to make work with the cache server (Unity Accelerator). There's a property in the ScriptedImporterAttribute for this, AllowCaching, which I have set to true.

I can see in the Editor.log that it requests the asset from the cache server, but it always leads to importing locally and uploading it to the server.

When I try importing from other computers connected to the same cache server, the same thing happens. It requests the asset, but ends up importing locally and uploading, under a new artifact ID each time.

The computers are using the same Unity version, same build platform. I'm starting to think ScriptedImporters just don't work with the cache server. Has anyone here gotten them working together?

#

The two examples of "real-world use of Scripted Importers" in the documentation page, Alembic and USD, both don't have the AllowCaching property set :/

waxen sandal
#

Does it say why?

#

Hashes don't match?

short tiger
# waxen sandal Does it say why?

The log just shows this:

Querying for cacheable assets in Cache Server:
    a02a15ed177f1324799d510af869c2e5:Assets/Some/Asset.asset
Start importing Assets/Some/Asset.asset using Guid(a02a15ed177f1324799d510af869c2e5) Importer(-1,00000000000000000000000000000000)  -> (artifact id: '86e37929ed0591015b6e0a36d7d561d2') in 45.094459 seconds 
Artifact(artifact id=86e37929ed0591015b6e0a36d7d561d2, static dependencies=7fab308d41bf758d740a910e050c7e25, content hash=7d01985cdef3d7b328a3f9384256403f) uploaded to cacheserver
#

The GUID is the same in all the logs, but the other ids/hashes after importing are different.

waxen sandal
#

Guessing something is messing with the hashing

shell beacon
#

How can I create a custom toolbar like this one in the scene view?

waxen sandal
#

Think so yeah

#

I always forget what it is called

shell beacon
#

Thanks!

cyan ginkgo
#

Totally realized I was one done from the right channel, my bad!

median ore
#

Hey there!

#

Hope y'all are having a good day

#

So I have a videogame and suspect there are memory leaks, but that's just a hunch

#

I want to check

#

So I installed the memory profiler package and started following the instructions provided in the Unity docs to detect memory leaks

#

My problem is the sixth step

#

In which I am supposed to load two empty scenes?

#

I am not sure if I understand what they mean

#

My knowledge is quite limited when it comes to Unity

#

But iirc to load a new scene you have to either put some sort of scene transition in your code or stop the player and manually open the second scene

#

But I think that when you stop the player, everything that is stored in the memory just gets freed

#

So I just wanted to confirm if in order to follow the tutorial I need to set up some sort of scene transition from within the game's code?

#

Code that takes me from the first empty scene to the main game scene, then to an empty scene and another empty scene

gloomy chasm
median ore
#

That makes sense

#

Something of a more general question about what it is I am trying to do, however

#

So what I am doing is basically comparing three snapshots of the game:

  1. An empty scene (no variables or assets loaded into memory yet)
  2. The main scene with all its assets loaded in memory
  3. Another empty scene where all assets would have been theoretically unloaded
#

To find out what the difference between what an empty scene looks like vs a supposedly empty scene

#

And if there is anything left over from the main scene that I want to test's snapshot, then that means that there might be a memory leak in my code?

#

Meaning UnloadUnusedAssets just removes assets that have been properly disposed of in code?

worldly ginkgo
#

anyone know the path to add a MenuItem to the context menu of scenes in the hierarchy? Or how to find out?

worldly ginkgo
#

Actually I'm now looking at the source code, and it doesn't seem possible/supported

whole steppe
#

anyone know how to change the cursor for the whole screen in unity editor? I want do make a position picking tool and change the cursor, when active

soft kiln
reef trail
#

Anyone else use Rider?

#

Sometimes, it'll stop auto formatting. Simple things like automatically adding a closing brace when I type an opening brace

#

Can't indent multiple lines of code with tab'

#

Basically anything beyond raw text stops working.

timid coyote
#

Im trying to take a ScriptableObject's fields and draw them in a custom window, but when i edit them into the window, they dont get saved, even thought im calling EditorUtility.SetDirty

private void DrawSentences(DialogueData dialogue)
        {
            if (dialogue == null)
                return;

            var dialogueProperty = new SerializedObject(dialogue);
            using (new GUILayout.VerticalScope())
            {
                for (int i = 0; i < dialogue.Length; i++)
                {
                    var sentencesProperty = dialogueProperty.FindProperty("sentences");
                    
                    if(i == 0)
                        Helpers.DrawHorizontalLine();

                    GUILayout.Label("Sentence " + (i + 1));
                    
                    var sentenceProperty = sentencesProperty.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(sentenceProperty);
                    
                    GUILayout.Space(5f);
                    Helpers.DrawHorizontalLine();
                }
            }
            
            var nextDialogueProperty = dialogueProperty.FindProperty("nextDialogue");
            EditorGUILayout.PropertyField(nextDialogueProperty);
            
            EditorUtility.SetDirty(dialogue);
            
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            
            DrawSentences(dialogue.NextDialogue);
        }
blissful sigil
#

Hey guys,

Does anyone know weather or not Unity allows custom asset updaters? Meaning I've an asset which I want to use my own updater to update it though my server.

gloomy chasm
gloomy chasm
blissful sigil
halcyon forum
#

Hi, I have a really simple question, how can I toggle a field based on an enum in the inspector?

clear kite
timid coyote
#

why does my Dialogue Data field shrinks whenever i add a new element to the list?
i use EditorGUILayout.PropertyField to draw both Dialogue Data and the elements
(Dialogue Data and Next Dialogue should be the same length)

waxen sandal
gloomy chasm
#

A bit of a long shot and I don't think there is. But anyone know if there is a way to get if a object is currently being moved in the scene via the transform handles?

waxen sandal
#

Isn't that just selection.activeobejct?

#

Selection.transforms

#

looks like it

gloomy chasm
# waxen sandal Selection.transforms

That is just the selected transforms, not if they are actually being changed. But I will look in that BuiltInTools thing, there might be something in there I could use.

waxen sandal
#

Oh I misread

#

I thought you meant the objects being moved not if they are moving

gloomy chasm
#

Ah

waxen sandal
#

Probably have to do something with the controlId and OnSceneGUI (and GUI Event)

gloomy chasm
#

Looks like I could maybe add a callback to the currentSceneGUI and get the hot control, check if it is a transform id, and check if selection has my object

#

Thanks Navi for the help!

timid coyote
#
var eventsIdProperty = sentenceProperty.FindPropertyRelative("eventsId");
EditorGUILayout.PropertyField(eventsIdProperty);

this time, this string array doesnt let me modify it, and i dont understand why.

#

but i can add elements to it, that are saved in the struct that is a part of a list

whole steppe
primal atlas
#

Hi, I need help with vs code with unity. Every time I open unity scripts on unity, it tells me to download mono every time. (I'm using mac)

wispy delta
#

My memory and googling skills are failing me. Is there a way to lock the editor while performing some async operation?

waxen sandal
#

There's that progress bar thing

wispy delta
#

I tried it but was still able to use the editor behind it

#

referring to EditorGUI.ProgressBar();

vale berry
#

I could use a hand; I'm trying to open an editor window from a custom property drawer. How can I edit the property in the window? Casting the type to property.objectReferenceValue gives me errors when I try to edit it.

gloomy chasm
vale berry
gloomy chasm
#

Though maybe just passing the window the object and path would be better...

vale berry
#

I plan to use the attribute in more than one place, so the number of objects that may end up using it is something like 3 or 4

wispy delta
sudden wasp
#

I'm working on writing a custom importer to set up animation events. I've already created the list of animation events from a .xml file in OnPreprocessModel, but it doesn't seem to want to apply them to the clip in OnPostprocessAnimation. I was under the impression that AnimationUtility.SetAnimationEvents(clip, eventList.ToArray()); should add my desired events eventList to the clip being supplied to OnPostProcessAnimation. However, once the import is done and I look at the animation clips attached to the .fbx file, they do not have any animation events

https://pastebin.com/eZyA4jq4

#

it should be noted in that code animationEvents is a temporary scriptable object created in OnPreprocessModel, and clipLookup is a dictionary that gets populated by that same scriptable object. clipLookup is keyed by the animation clip's name, and holds a custom class AnimationClipEvents with a list of AnimationEventMarker (themselves holding a float time and string value which is parsed to get the function name and any parameter to pass)

#

I've also tried duplicating the animation clip from the .fbx and saving it separately like so, but it doesn't seem to want to create a .anim file (animation clip) this way for some reason:

    AnimationClip CreateAnimationClip(AnimationClip importedClip)
    {
        
        string path = AssetDatabase.GenerateUniqueAssetPath(assetPath.Substring(0, assetPath.LastIndexOf("/")) + importedClip.name + ".anim");
        AnimationClip temp = new AnimationClip();
        EditorUtility.CopySerialized(importedClip, temp);
        AssetDatabase.CreateAsset(temp, path); //create instance at newPath 
        AssetDatabase.SaveAssets(); //save the asset database to keep this item

        return temp;
    }

The idea being that I would instead put the animation events on the duplicate, but I can't do that if I can't save it

sudden wasp
#

Scratch that, turns out it is saving after all (verified with debug logs). But for some reason the animation clip doesn't show the event in the inspector?

obtuse basin
#

Hi guys! I'm hoping to get some help. I'm trying to set up some custom things to hide/show in the inspector but I don't have the typical case. I'm using generic class as Serializable which is used within a scriptable object (list). Any ideas how to manipulate this in this case? Help would be greatly appreciated! 🙂

gloomy chasm
# obtuse basin Hi guys! I'm hoping to get some help. I'm trying to set up some custom things to...

If you want to change how a plain old C# object is drawn, then you create a PropertyDrawer for it. Editor is only for objects that inherit from UnityEngine.Object

Use SerializedProperty and SerializedObject to get and manipulate data in the Unity editor. That way you can ensure changes are saved and undo operations are registered for the changes. You can see the pinned message in this channel for links to the docs.

But to answer your question for how you are doing it now. You set type in the CustomEditor to be the SO (typeof(SO_Dialog)). And then in your OnInspectorGUI() you do var targetDialog = target as Dialog;

candid bolt
#

When you right click on an asset and go 'properties', Unity opens a nice little properties inspector window specific to the asset. I'd like to make a button in a custom inspector that opens the properties window for a given asset via script. Anyone know this can be done?

#

I don't want it to select and view in the current inspector because I'd like both to be viewable simultaneously. Just unsure what Unity calls these Properties windows.

candid bolt
#

Well this seems a little roundabout but it works cs EditorApplication.ExecuteMenuItem("Assets/Properties...");

meager lynx
#

Do you guys know how I can get the values from an array on a ScriptableObject to a property drawer field within that Scriptable Object? I need to fill a dropdown with the values of the "Object Events".

alpine bolt
#

What are the best ways to try and get SO duplication Awake/OnEnable/OnValidate methods fired just once?

alpine bolt
alpine bolt
gloomy chasm
alpine bolt
# gloomy chasm Are you sure it is the same object running it? And how are you duplicating?

Pretty sure. CTRL+D

using TG.Utilities.Extensions;
using UnityEngine;

[CreateAssetMenu()]
public class TestSO : ScriptableObject
{
    private bool testBool;

    private void Awake()
    {
        if (Event.current.IsDuplicate() && !testBool)
        {
            testBool = true;
            Debug.Log("Awake " + GetInstanceID());
        }
    }

    private void OnEnable()
    {
        if (Event.current.IsDuplicate() && !testBool)
        {
            testBool = true;
            Debug.Log("OnEnable " + GetInstanceID());
        }  
    }

    private void OnValidate()
    {
        if (Event.current.IsDuplicate() && !testBool)
        {
            testBool = true;
            Debug.Log("OnValidate " + GetInstanceID());
        }
    }
}``` you can test it out
alpine bolt
short venture
#

you would need to Serialize testBool if you want it to persist

alpine bolt
#

I've edited my script to better show that even without setting testbool as false, OnValidate runs twice

alpine bolt
short venture
alpine bolt
#
public static bool IsDuplicate(this Event e) => 
e is { type: EventType.Used, commandName: "Duplicate" };
```btw, this is my IsDuplicate extension method
gloomy chasm
meager lynx
waxen sandal
#

What's an object event

alpine bolt
#

I was about to ask that

alpine bolt
# gloomy chasm I could be wrong, but what might be happening is the instance is created which f...
[SerializeReference] private NodeTree nodeTree;

private void Awake()
{
    if (Event.current.IsDuplicate() && !checkingDuplicate)
    {
        checkingDuplicate = true;
        if (this.IsUnique())
            Debug.Log(Title);
        else
        {
            Debug.Log("Duplicating " + Title);
            Clone();
        }
    }
}```
```cs
public bool IsUnique()
{
    return GetInstanceID() == this.NodeTree.objectOwnerInstanceID;
}

in the NodeTreeScriptableObject. I'm trying to handle object duplication whenever I manually duplicate a ScriptableObject.
Clone() basically Binds a new context to the NodeTree POCO object: changes Node GUIDs inside NodeTree POCO Object, iterates some lists, etc... Basically handles duplication to make everything unique. But every time it runs twice. It sort of seems it is async or runs twice because it's using 2 different copies, BeforeSaveAsset and AfterSaveAsset.

gloomy chasm
#

Because imo it isn't really the objects responsibility to know if it has been duplicated in this sort of scenario.

#

Iirc the way I have done it in the past is to store the GUID of the asset in the asset. Then in the post process I compare the stored GUID with the actual asset GUID. If they are different that means it is a duplicate.

alpine bolt
#

Alright I'll test it out. Not knowing some classes exist is the real issue 😛 Thanks

gloomy chasm
#

Sure thing! Best of luck!

alpine bolt
#

One more thing, is it normal for an importedAsset to also be the duplicated FROM asset?

#

Duplicating one, imports FROM and TO objects. Weird

gloomy chasm
#

Oh nvm I misread. Uhh... idk, try in a new project if you are not sure 🙂

pure siren
#

Is there a way to get current inspector height for custom editor?

alpine bolt
pure siren
alpine bolt
# pure siren how though?
[CustomEditor(typeof(MyScript))]
public class MyScriptEditor : Editor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        Debug.Log(Screen.height);
    }
}```
pure siren
alpine bolt
pure siren
#

It returns the game views resolution set height, but if I move my mouse over the inspector it returns the inspector height

gloomy chasm
pure siren
gloomy chasm
pure siren
oblique sky
#

is there a way to make InfoBoxes in Odin appear below the properties? having them above the property is pretty unintuitive and clunky imo

gloomy chasm
gray cedar
#

How can I get the System.Type of a field with [SerializeReference]?

#

Nvm, solved the issue

oblique sky
#

fun seeing what people create with odin though

gloomy chasm
#

Or every day for an hour or two I can't remember which

oblique sky
#

I know this one girl on an art server I've been in for like 2 and a half years and she's STILL on there answering questions every day

short venture
oblique sky
#

to be honest even joining another server to ask the question was a bit beyond the value I'd get out of the answer but my curiosity won over so

bronze knoll
#

Does anybody know how these are implemented, if they're instantiated from prefabs or created entirely from code?
I want to imitate them for one of my own things.

gloomy chasm
bronze knoll
gloomy chasm
bronze knoll
gloomy chasm
bronze knoll
#

Excellent. Thank you very much!

bronze knoll
#

Oh, wow. Thank you so much! 🙇 🙇

gloomy chasm
#

Nothing complex as you can see

jovial plaza
#

Hi Folks, I am trying to create a list of points around a race track (In order to determine the percentage around the track for a race-timing asset I'm working on). I was wondering if there is a way to edit these points on the screen without having to create temporary game objects?

#

I am using OnDrawGizmos to visualise a list of Vector3s like this: -

#

Is it possible to select these dots and allow the user to move / delete them?

gloomy chasm
jovial plaza
#

but I'm not sure how you'd only show the "selected" one

gloomy chasm
#

You mean only show the handle for the selected point?

jovial plaza
#

I mean I have all the Vector3s in a List in a ScriptableObject

#

I doesn't have any concept of selected

#

I just want them to be visible / editable in the Editor

gloomy chasm
#

If you have a component then you would create a custom editor for it and use the OnSceneGUI method and draw the handles in that

jovial plaza
#

I have a TrackMarkerManager to hold them all

gloomy chasm
#

Nice, so you create a custom editor for that. And instead of drawing gizmos, you do something like Handles.DrawSphereHandle because you can get when that is selected. If it is selected, you store that index in a field and than instead of drawing the sphere you draw the position handle

jovial plaza
#

Cool, does that mean each SphereHandle is individually selectable (even through I'll draw one for each point)

#

Thanks for your help btw, I really appreciate it 🙂

gloomy chasm
jovial plaza
gloomy chasm
#

Your welcome and good luck! 😄

gloomy chasm
# jovial plaza Brilliant, sounds exactly what I need, thanks for your help!

Oh one last thing. If you are setting values of a component or ScriptableObject inside the editor it is best to use SerializedObject and SerializedProperty because that will make sure the values are saved and automatically handles undo/redo. There are links to the docs in the pinned message in this channel.

#

It is more work, but it is definitely worth it.

jovial plaza
#

Yeah, definitely sounds worth doing. Thanks again!

flint garnet
#
.pa-style-utilites__horizontal-group:active
{
    background-color: yellow;
}
``` why this active state not working to change my visual element background color??, this is apply to foldout anyway
hoary sparrow
#

received this error randomly, is this something to be concerned about?

alpine bolt
#

When my editor window is open, something is causing to lose focus of the selections I have in Project tab. What could it be? I’m using packages like UIToolkit and GraphView

alpine bolt
#

Figured out I had been calling the editor window GetWindow() in a GraphView.Node class and was causing these problems.

alpine bolt
hoary sparrow
#

hey wondering how i can make my public strings be large like you see in text mesh pro component's strings?

waxen sandal
#

You meant textarea?

hoary sparrow
#

perhaps?

hoary sparrow
#

ah im already using that, that doesnt really look like text mesh pro's one though

#

hold on ill send a screenshot comparing

waxen sandal
#

Idk waht the text mesh pro one is

hoary sparrow
#

this is the text mesh pro one

waxen sandal
#

Probably the same with just minLines set to something higher?

hoary sparrow
#

this is text area

hoary sparrow
#

yup it fixed it, thanks so much!

weak spoke
alpine bolt
#

How do I run a .package file?

waxen sandal
#

A what now

alpine bolt
#

Rephrasing: How do I execute a .unitypackage file in project via code

#

And with this I understood I was searching the wrong extension in google and found the answer now, easily :c

whole steppe
#

I'm trying to set the position of sub-state machines in (this) example => https://paste.mod.gg/hrhzegsbvsfh/0;

however, they don't seem to change position at all, do you have any idea?

waxen sandal
#

That's very niche but I'd recommend to look at the animator source to see how they change it

whole steppe
#

do you happen to know where could I find that?

waxen sandal
whole steppe
#

which one of the following am I better of => off going with for a popup menu?

thiscs private int selected_resolution; private string[] resolution_options = new[] { "32", "64", "128", "256", "512", "1024" };``````cs selected_resolution = EditorGUILayout.Popup("texture resolution:", selected_resolution, resolution_options);``````cs private int GetSelectedResolution() { switch (selected_resolution) { case 1: return 64; case 2: return 128; case 3: return 256; case 4: return 512; case 5: return 1024; default: return 32; } }
or thiscs private ResolutionRatio selected_resolution;``````cs selected_resolution = (ResolutionRatio)EditorGUILayout.EnumPopup("texture resolution (enum):", selected_resolution);``````cs private enum ResolutionRatio : int { _32 = 32, _64 = 64, _128 = 128, _256 = 256, _512 = 512, _1024 = 1024 }

whole steppe
#

yes? no? nothing?

gloomy chasm
#

Probably the enum would be better as you could use it for other things and it is more constrained and explicit than an int

whole steppe
# gloomy chasm Well, what is the end use going to be?

as the name suggests, it's supposed to represent a texture resolution of a 1 : 1 ratio, casting the enum returns the assigned value, I needed to ask first as I've been recommended to use the default popup menu before compaired to the enum one...

#

however, in this case, it seems the right choice!

#

thanks for feedback sir

gloomy chasm
whole steppe
#

I luv u, plz marry me!!!!!

hearty basin
#

Hello ! I'm not sure where to post my question. Does somebody here have already use the Unity Python package ? I would like to integrate a Python Lib for a custom tool, but I can't find a way to get a return value from the two exposed methods to run python code : PythonRunner.RunString() and PythonRunner.RunFile(). Does somebody have already achieve this ?

grave kite
#

I'm wanting an editor button for some debugging stuff that'll start the game with some simulated start, then drop me off at that point, is there a method or something that starts the debugging? all I really need is an entrypoint to start the run and play editor function, and then run some code right after

foggy cairn
whole steppe
foggy cairn
whole steppe
#

the other what now?? y'know what... you're welcome!~

tranquil sage
#

Is it possible to add another custom filter for logging in addition to these three?

blazing juniper
#

anyone know why my width and height aren't editable? I want to run the generate grid function when they change but I can't change their value in editor
https://pastebin.com/dLd3A6N8

#

or to better ask it does intfield on it's own let a value be editable or is there a step my smoothbrain is missing

visual stag
blazing juniper
#

got it thanks

visual stag
#

Also, without Undo or SerializedProperty it will not persist changes because the serialization system will not be aware of it

blazing juniper
#

so if i understand correctly dirtying is a way to set up your changes in the inspector to be saved and undone?

gloomy chasm
blazing juniper
#

is there any equivelant to BeginChangeCheck i can use because what I've got ain't working
https://pastebin.com/dLd3A6N8
(editor script on the bottom of the normal one)

#

just want to call generategrid when width and length change

visual stag
blazing juniper
#

doesn't work

#

huh

#

it works

#

ok one question is there a on undo event i could use? for when i undo specific variables

unkempt fern
#

Guys, how can i force update edit mode ? I tried

UnityEditor.EditorApplication.QueuePlayerLoopUpdate();
UnityEditor.SceneView.RepaintAll();
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();

But it'll only work if the scene view is opened. If the scene view is closed, the game view will update with lag. Any ideas ?

narrow cipher
#

if i downloaded vcs (visual code studio) separate from unity how add it to unity or do i have to download from unity?

radiant radish
#

is there a way to load VST plugins yet?

#

I know you can build audio effects and stuff with JUCE, I've done that

#

but I want to use some other vst, a synth, to dynamically produce effects

short tiger
radiant radish
#

no, I haven't stumbled upon that in my research

#

going on the github page, it says its used to build vst plugins

short tiger
radiant radish
#

how?

short tiger
radiant radish
#

ok so this would compile out to dll which can be interfaced to with unity

short tiger
radiant radish
#

it looks pretty straight forward, get the plugin path, then just pass in the parameters I need through a linked mono behavior that is FFI'd in

#

which means i have to remove the form, make everything that is done through the form, made possible through the linker

velvet badge
#

Hello guys! I have a question regarding recompile times when i change a script in Unity. So i am aware of assembly definitions already and i can see how this will improve the issue. Another thing i am thinking is that for now i keep my projects on a HDD so anything Unity loads it loads it from the HDD. Will switching to an M2 SDD like the Samsung 980 Evo that also has a built in DRAM help me lower those times?

#

I am not sure if the hard drive matters when recompiling stuff, but it seems to me that it probably does and if it does then that switch combined with assembly definitions could eliminate the problem for me

tranquil sage
frozen perch
#

Hiya, I'm trying to make 2 fields appear next to each other in the inspector:

#

I would like to forgo the names ("Sprite" and " Frames"), and have the two fields next to each other

#

Here's the current implementation:

#

and base class:

gloomy chasm
frozen perch
#

you are a god ❤️

#

I imagine there's a similar line to have them extend to the size of the Inspector?

gloomy chasm
frozen perch
#

I had a feeling I had, so I started splitting them anyways. Thx!

#

like a charm 🙂

bronze knoll
#

is there a way to add properties to an inspector that don't exist in the type being inspected?

gloomy chasm
bronze knoll
gloomy chasm
bronze knoll
#

IMGUI

#

is one preferable to the other?

gloomy chasm
#

myInt = EditorGUILayout.IntField("This isn't on the object", myInt);

#

myInt can be from anywhere, you can define it on the editor class itself.

gloomy chasm
abstract solar
#

how do I make clicking a ScriptableObject asset in the asset browser open it in my custom editor?

quaint zephyr
#

What PrefabUtility method will allow you to input a game object instance and get back its Prefab asset?

crimson yarrow
#

I have a question about code suggestions between VS Code and VS Community although im not sure if its the right channel to ask

#

Im trying to get this kind of smart suggestion on Vs Code but can't seem to figure how

visual stag
crimson yarrow
visual stag
#

That's configured, yes

crimson yarrow
#

Although I've never tried to use Github Copilot on VS community, im guessing it's there by default

visual stag
#

I don't think it's default for any IDE

crimson yarrow
#

Well I've only downloaded VS community 2022 and added the Unity module

#

I've been trying to figure out how I can get this smart completion on Vs code

visual stag
crimson yarrow
#

alright thx

#

also I've been having a Project loading failed which looks weird but Im not sure if it's affecting auto completion

#

I tried looking up how to fix it although the error is too big to give a search with an accurate solution

peak bloom
#

MaterialProperty.vectorValue How would I get vector2/vector3?

spark lotus
#

Why would you want a Vec2 or Vec3? The return value is that of the material often interpreted as Mat4 (Matrix)

peak bloom
#

I don't know man 🤣 , I was tasked to make a material property binder like the one used in ue which my 1st time ever touching custom editor for a material 😄

#

With the help of a colleague it's solved now 🔥 ... Employee of the month right here 🥳

grave mortar
#

Greetings. This is my first time taking a dive into Custom Inspectors. Here is what I'd like to achieve, but not sure if its possible:

I'd like an expandable array/list/dictionary/table (not exactly sure what it would be) that is like a row, with three columns of data:
VariableType Dropdown (maybe this is an enum?);
An Object Field (this is actually going to be a place to drop in an InputActionReference);
And then a name for the variable (move, jump, etc)

Is this even possible if the original monobehavior doesn't have these variables?

waxen sandal
#

You can draw whatever you like but you can't really save it if it's not on your mono behaviour

olive falcon
#

how would you change the label in the editor where it says 'element 0' I want it to match the name of the 'product' variable i have

vestal forge
#

Am I doing something wrong here? For some reason when I view this window from certain monitors it just breaks the layout. The monitors that break it are 4k while the ones that work are 1080p and 1080p ultrawide. The code for the window is quite literally just three rects with their height being set to (Screen.height/sectionCount)*sectionNumber

#

The button I set to print out the resolution of Screen.height and Screen.width and the output is what I expected it to be

vestal forge
#

I think the issue comes from the actual scaling of the monitors, since disabling scaling in preferences fixes it...

robust mantle
#

hey guys, im currently confused. i try to duplicate an shadergraph (premade template) per button. so i created a simple static function for it :

#

but i have issues to get Type,name,and Duplicate Access. what confuses me because AssetDatabase is there any idea?

waxen sandal
#

DuplicateAsset is not a public api

#

Also, you're using system.object not UnityEngine.Object

#

You can use CopyAsset instead

#

Idk why Type doesn't work but probably because you forgot to include system

robust mantle
#

Thanks the Duplicate one, what showed me up was the issue it seems. didnt noticed thats not a public api because it showed up. thanks again!

#

yea only the name will not work yet for any reason. but only replacing the Duplicate solved all the rest :

#

strange

robust mantle
#

doesnt solved it. also with System.Object name not works

waxen sandal
#

What did you change

robust mantle
#

the unity Engine. i removed object is enough at all. and on asset variable i added system.Object but name is still same

waxen sandal
#

Your sentences makes no sense

#

But (once again) system.object is the wrong type, you need to use unityengine.object

robust mantle
#

no my wierd english explained wrong i meaned i removed the System.Object like u mentioned and added the Engine one. is working now thanks again

gaunt oxide
waxen sandal
#

Lets not turn this into a chat on how to configure your IDE

gaunt oxide
gaunt oxide
alpine bolt
#

Anyone knows how I can trigger GraphView.Edge on drop?

gloomy chasm
alpine bolt
#

So I want to drop the edge and trigger a contextual menu. I've tried to get the edge from GraphViewChange.elementsToRemove and it seems that the edge was never there to begin with

zealous coral
#

is there where i can ask about ScriptedImporter?

#

i am facing the trouble of getting a consistent reference to extra objects thats created & added during the import of an asset with ScriptedImporter

brazen solar
#

Anyone with experience in working with the Playfab SDK here?

alpine bolt
sour plinth
#

anyone know why my unity 2021 doesn't have visual scripting? I'm watching a video and it says I should not have to import anything and that it would already be there, but it isn't for me

gloomy chasm
gloomy chasm
zealous coral
#

it's part of a bigger package called SuperTiled2Unity but let me try to simplify it and focus at the main parts

#

during the import process, these 4 main functions will be called (labelled 1 2 3 4)
functions 1~3 is there by default and everything works well
function 4 is a new function i added for my custom needs

#

at the end of BuildTileset is this function which creates a lot of SuperTile instances (a class that inherits from Unity's Tile class) and they all gets added to the main asset

alpine bolt
#

Is it possible to "fake" a ContextualMenuPopulateEvent object?

zealous coral
zealous coral
#

(let me finish describing my issue 1st anyway)

alpine bolt
# zealous coral

I used to have a code like this. I gave up doing AddObjectToAsset and converted everything to a POCO stored in a ScriptableObject.

zealous coral
#

and then, inside function 4, i need to get references of those tiles created during function3, and put those object references inside another scriptable object

zealous coral
alpine bolt
#

That was what I had to do 😛

#

I had so many issues I couldn't figure out

gloomy chasm
zealous coral
zealous coral
# zealous coral

I debug.logged the instanceID of things like wad's shown at the bottom of this image
the instance ID from the log, and the actual instanceID shown when i selected the same object using Debug Mode inspector, is different

alpine bolt
alpine bolt
zealous coral
# zealous coral

so it SEEMS like, the objects that are created during this process, and what's ACTUALLY being "registered" to the assetdatabase, is different?

zealous coral
gloomy chasm
gloomy chasm
zealous coral
#

TryGetTile is also what the package itself actually used to "locate" a Tile as well when it tries to find a Tile and change properties in it (and of course it worked well on its own)

#

so i simply used the same method to find a tile, and then put it inside my "WangTile" scriptableobject

#

while i step through the code line by line during the import process, everything works well and looks well inside VisualStudio's watch list

#

the tile references are all there, with proper name and everything
but as soon as the whole import process is done, and i check things at this WangTile object, the references are all "Missing references" (or whatever the actual wording is, u get wad i mean)

zealous coral
gloomy chasm
#

I have been looking at the source for the package and I'm not sure what to tell you, it looks okay and like your code should work. Though it does strike me that something is off, I just can't put my finger on what exactly. You might be able to find something with google

zealous coral
#

i tried googling, nothing came up

#

¯_(ツ)_/¯

#

it does look and feel more like an "Unity issue" to me, i know what i am doing
the funniest thing is, the asset itself managed to do similar thing somehow

#

this is the main asset

gloomy chasm
#

Well the issue is referencing other subassets from the subassets correct?

zealous coral
#

inside the inspector (in debug mode), it has this SuperTileset script which stores all the tile references

zealous coral
gloomy chasm
#

Hmm, the only thing I can think of is that it is a order issue maybe? Are you adding the subassets before referencing them?

zealous coral
#

NewWang Tile is my "database" and i wanna get references to those Tile_Tilesetxxxxxxxxx subassets

zealous coral
gloomy chasm
zealous coral
#

the Tile subassets are definitely being added to the mainobject 1st, that's done in function 2

#

and i am retrieving the references in function 4

gloomy chasm
zealous coral
#

righttttt

#

that's what i am guessing too

gloomy chasm
#

easy fix

#

Just use the global callback for when an asset is imported

zealous coral
#

is there one ?

zealous coral
#

hmmmmmmmmmmmm alright, will try that

#

not the cleanest way, but at least it can be filtered/limited somehow

gloomy chasm
#

Yeah, will need to check the file extension and if it is your extension than you use LoadAllAtPath and then add them to the manager SO. Might need to do a check if they are already added or something

zealous coral
#

will need an update to my implementation, but at least there's a way now i believe
thanks for the help!

gloomy chasm
#

Sure thing! Best of luck! 😄

zealous coral
#

nice, it finally worked

#

it should have worked last thursday

alpine bolt
gloomy chasm
alpine bolt
gloomy chasm
alpine bolt
gloomy chasm
brazen anvil
#

idk if this is a place to ask this question but what does this error mean in the bottom right corner

whole steppe
#

Just follow the step by step that is success

vivid flower
#

Not truly extensions, the Editor Inspector Presets feature... I've been using forever, but have just found it not storing object assignments in fields within the Inspector... is this a known bug?

green zenith
#

Hi there!

I'm currently implementing my own Terrain solution and I'd like to add some editor tools for the user.

I came across the EditorTool-API that allows me to add a button to the Unity's default GameObject tools (like Rotate, Move, Scale, ...). Together with a EditorToolContext the toolbar will show the custom buttons only if e.g. an GameObject with a certain component is selected.

For example, the Splines packages is using that to provide specialised spline editing tools when you switch the context.

In my case, I want to have a EditorToolbarDropdownToggle which is the perfect control for my use case: When clicking the dropdown-button I want to show a selection dialog of paint that the user can choose from. Then, if you click the toggle button you can enable/disable paint mode.

I have achieved this using my own overlay: [Image 1]

You can see the overlay at the button with a EditorToolbarDropdownToggle. However, I want to integrate that into the toolbar above, like the Splines package does: [Image 2]

However, I was not be able to use an EditorToolbarDropdownToggle in that menu. The EditorToolAttribute works for classes that inherit from EditorTool only.

The thing is, having a second toolbar just for my terrain would be fine. However, I fear that it will somehow interfere with the current active GameObject tool.
I was thinking about providing an empty EditorToolContext so it does not interfere with it. But that looks like a strange hack to me.
Another thing could be using the ToolManager somehow to change active tool. However, it also needs to be a class inheriting from EditorTool.

The best thing would be the integration of the dropdown button into the Unity toolbar.

Thanks!

steel cedar
#

I'm writing a PropertyDrawer and it seems like it's drawing 100s of times pr second! My screen is only 60hz so this seems kind of overkill... Is this normal??? Is there a way to tell Unity only to redraw at a certain time?

loud steppe
#

how do i replicate the modern list field editorgui into a custom editor?

eternal girder
#

How does one make a scriptable object be based on what is currently selected in the project explorer?

#

As a material does to a shader for instance

#

when you right click the shader and select create material, it creates a material based on the shader

#

is there anyway to do this with custom scriptable objects?

#

there must be a way

weak spoke
#

that way you get the path then you can get the asset via the asset database

eternal girder
#

But how do I run this when the scriptable object is created?

gloomy chasm
#

You can scroll down a bit on that answer that Malzbier linked and there is a longer answer that has more info in it

gloomy chasm
rigid smelt
#

Hey guys

#

currently trying to import a package from git to unity

#

but it isn't working

#

shows an error

#

any clue why that might be?

#

I really don't know what's the problem

#

or what it seems to be

twin dawn
# rigid smelt

looks like possibly you tried to do "add by name" but then used a git url? Should be "Add from Git URL..."

rigid smelt
#

It still isn't working but I imported in a different way

#

Ty tho

last wolf
#

Anyone know how to move the red up to the blue?

waxen sandal
#

Change the priority parameter

last wolf
#

how would i do that?

waxen sandal
#

It's in the MenuItem constructor

last wolf
#

ah alr thanks man

pine gull
#

hey so I have a rather complicated type of custom editor inspector window but I want to enable the ability to select multiple gameobjects with the script and modify them all at once
now what makes this complicated is that in each gameObject instance with script, theres several settings
in the image per say, the selected material changes an array index that the rest of the variables write to(so I can have mulitple "materials" and edit them from one thing)
How do I make it so I can select multiple gameobjects and still modify say the first array index in all of them?

#

that makes no sense.,. lemme try again
basically I have a gameobject with say 4 materials
the SelectedMaterial directly maps to the those materials
clicking it changes which material your modifying, and the sliders below change the values of the material selected
how do I make it so I can select multiple gameobjects and change the first material attributes of all of them?(they dont actually map to the material directly, its just easier to consider that they do)

#

adding the thing of CanEditMultipleObjects doesnt work, I assume because of the array thing

gloomy chasm
#

Is it a custom editor? And what do you mean 'it doesn't work'?

pine gull
#

it doesnt edit multiple only the last one selected
and its a custom editor inspector script

gloomy chasm
#

Are you using SerializedProperties, or are you editing the values directly?

#

I assume directly because otherwise it would just work 😉

pine gull
#

I have them like this in the editor script:
and I have the actual variables serializedfields

gloomy chasm
pine gull
#

oh? ok!

gloomy chasm
#

using that will get you multi object editing, saving changes, undo support, and prefab overrides all for 'free' without any extra work

pine gull
#

thanks!

#

will this screw things up?

gloomy chasm
pine gull
#

will this way of doing things screw things up?
this controls which material I am editing

gloomy chasm
#

You just get the serialized property for the different arrays you have and then get the element at the selected index and set its value

pine gull
#

how do I get the array element of a serialized property?

gloomy chasm
#

You are literally doing it like 4 lines...

#

Unless you just copy pasted code without actually reading it 👀

pine gull
#

no this is my own

#

been awhile since I wrot eit

gloomy chasm
#

Ahh

#

Look at what you did with Names

pine gull
#

because I understand like .GetFloat
but how do you do like.GetArrayVector

gloomy chasm
#

No, .GetArrayElementAtIndex(index)

pine gull
#

oh!

gloomy chasm
#

That gets you the serialized property that contains the value

pine gull
#

whats the way to get a vector3 from this?

gloomy chasm
#

property.vector3Value that is how it is for all 'basic' values

pine gull
#

ahhh thanks couldnt find it

gloomy chasm
#

typeNameValue

pine gull
#

wait what if its an enum

gloomy chasm
#

Then use the properties with enum in their name 😛

pine gull
#

ahhhh thanks

#

yep that works! thanks!@

limber geyser
#

Is it possible to see the hierachy live for a development build?

#

Everything works great in editor play mode, but theres a bug after building.

#

Some shader values seem to be wrong, and Id like to verify the values

fervent kelp
#

Hello, I need to make my own graphview thing and was wondering if there is a way to get the inputPorts to go on the top and bottom. I know the API is based on the shader graph that unity does so i am guessing its impossible?

thanks in advance

fervent kelp
gloomy chasm
fervent kelp
gloomy chasm
#

Oh lol

fervent kelp
#

you see?

gloomy chasm
gloomy chasm
fervent kelp
fervent kelp
gloomy chasm
fervent kelp
#

but now isnt doing it anymore

#

but its ok dude its nothing major tbh

gloomy chasm
fervent kelp
gloomy chasm
#

Thinking about it you could probably inherit from Node and manually rearrange the child elements, but that seems pretty hacky and gross to me.

alpine bolt
#

Yeah it’s common to inherit some classes or create new ones mimicking already existing classes to solve problems in GraphView.

pine gull
gloomy chasm
pine gull
#

yeah im realizing that now... so I need to do trickery with Selection to update objects that are selected right?

#

how expensive is this to do?

gloomy chasm
#

serializedObject gives you everything you need

pine gull
#

oh really?

gloomy chasm
#

What are you trying to do exactly?

pine gull
#

so I have say 5000 gameobjects with a specific script
Whenever a value changes in one of those scripts, I need to add it to a que so it can be updated without updating EVERY gameobject with the script
this script is the same script that the custom inspector window leads to

gloomy chasm
pine gull
#

yes

#

this is fine usually cuz I can just use OnInspectorGUI to update only the selected one

#

but this doesnt work with mutliple selections

gloomy chasm
#

That is exactly how the editor works... you have to put in a lot of work to make it not work like that...

pine gull
#

yes

#

wait what

#

OnInspectorGUI is supposed to be called on all objects selected?

gloomy chasm
#

OnInspectorGUI is called only for the instance or instances that are shown in the inspector window

#

You can lock the inspector window or open property windows, so what is shown in the inspector does not necessarily mean that is what is selected.

pine gull
#

hell ok

#

so is there any way to do this then

gloomy chasm
#

my man... I am telling you that it literally does 100% exactly what you want

#

as is

pine gull
#

hmmm so why dont it be workin

gloomy chasm
#

Well, since I have no idea what your code looks like I really can't say 😛

pine gull
#

fair

#

OH HECK OK I SEE

#

OnInspectorGUI updates the currently selected object in the inspector

gloomy chasm
#

Yeah

pine gull
#

or rather whichever one I tab over

#

in the case of selecting multiple its whichever one you selected last

#

no thats not right either

gloomy chasm
#

You will notice that there is target and targets

pine gull
#

oooo

gloomy chasm
#

That is why you use SerializedObject as you just set the value and it sets it for all of the targets and handles the UI if the values are not the same for all of the targets

pine gull
#

got it

#

I think

#

so doing serializedobject.FindProperty("property").GetArrayElementAtindex(a).floatValue = E
will set that property for all objects?

#

what if one propertyof them is inconsistent?

#

or different
for instance an array with a different length

gloomy chasm
gloomy chasm
pine gull
#

it yelled at me

#

but this is where it yelled

#

it said t1 was out of range

gloomy chasm
#

Makes sen... what are you doing...??

warm axle
#

how do you make a custom editor script?

whole steppe
#

for some reason I keep getting the error in the image below...

It's originating from a CustomEditor that's meant to draw the inspector of a StateMachineBehavior

how to fix it/make it stop?

whole steppe
warm axle
#

i want to make a weapon script with an enum when melee is selected it will show variables like damage and range and when gun is selected it will show variables such as fire rate, damage etc

short venture
#

lots of resources

warm axle
#

I always first google my problems but it didn’t give what I was looking for

gloomy chasm
short venture
#

well you are unlikely to get something doing exactly what you want but if you cannot figure it out from the resources available it's probable that custom editors are not for you

gloomy chasm
warm axle
#

Well you are correct but I am a beginner so can’t say I would be able to achieve much

short venture
#

I think he wanted copy/paste code

gloomy chasm
#

Lets not assume things. We are here to help 🙂

warm axle
#

I mainly write my code but when it is an entire different topic that I don’t understand I tend to understand it first then code 🙂

gloomy chasm
#

Feel free to ask if you have more questions after looking at the results of what I suggested to google. But I think it should give you what you want.

warm axle
#

Thanks 👍

#

If there are two editor scripts will unity use the one that was edited recently?

short venture
#

what? You cannot have more than 1 script to edit an object

wispy delta
#

you can using inheritance

#

derived classes take priority. this is how you can provide custom editor to replace/extend ones written by unity

#

but also the custom editor attribute has an isFallback flag and unity prefer custom editors where the value is false

warm axle
#

I downloaded an Asset and it had an editor script so I was just wondering if the one I created and the other one would clash

gloomy chasm
warm axle
#

Yes

gloomy chasm
#

Oh, you can have as many of those as you want

warm axle
#

Thanks 👍

short venture
polar seal
#

hi

#

idk why but the Destroy() is not working

#

what should i do

gloomy chasm
polar seal
#

but isnt it a problem with the editor

#

cause in the course its working

gloomy chasm
polar seal
#

oh alr

gloomy chasm
#

As you can see by the description of the channel at the top 🙂

polar seal
#

alr mb

gloomy chasm
#

No problem

whole steppe
# warm axle i want to make a weapon script with an enum when melee is selected it will show ...

hey! sorry had to leave at that time, so yea, do what you've been recommended to so far!

I understand your situation, it's not easy as it seems at first, however! It's super easy!
no magic required, just logic.

to start off, Unity likes your Editor scripts inside a folder named Editor, if I'm not mistaken you can have it anywhere in your project.
I'd still recommend to have it in the Assets root to make things simple. you can read more about this here => https://docs.unity3d.com/Manual/SpecialFolders.html;

second, have to make a new script which inherits from the Editor class instead of MonoBehaviour. here's info about it => https://docs.unity3d.com/ScriptReference/Editor.html;

this script should have the CustomEditor attribute on the top of its class, this takes a type parameter, the type of YourScript, more about it here => https://docs.unity3d.com/ScriptReference/CustomEditor.html;
this will tell Unity which script this editor is for.

third, override the OnInspectorGUI() to begin creating your own GUI, for the sake of getting a grasp of this Editor thing, will do it the easy way:

you'll have to declare `SerializedProperty`s to store your `YourScript` variable values temporarily, those can hold a lot of data types! more about them here => https://docs.unity3d.com/ScriptReference/SerializedProperty.html;
you'll need to feed the actual variable values to those serialized properties in the `OnEnable()` method to minimize calls, then using the `serializedObject` => https://docs.unity3d.com/ScriptReference/Editor-serializedObject.html;
property, you call the `FindProperty()` method to get the values by passing their declaration name as string parameter => https://docs.unity3d.com/ScriptReference/SerializedObject.FindProperty.html;

hold up there's more!

#

now using the selected Enum value something like this per se: SerializedProperty tempEnumType; then tempEnumType.enumValueFlag with maybe a switch you can draw a property GUI with => EditorGUILayout.PropertyField();
just make sure to call serializedObject.Update(); before changing the value and serializedObject.ApplyModifiedProperties(); after the value has been changed!

more about them here: https://docs.unity3d.com/ScriptReference/SerializedObject.Update.html, https://docs.unity3d.com/ScriptReference/EditorGUILayout.PropertyField.html, https://docs.unity3d.com/ScriptReference/SerializedObject.ApplyModifiedProperties.html;

whole steppe
#

I don't know about you, but imma a copy/paste person, (here)'s a visual example if that makes it easier => it has been updated it doesn't completely represent what has been described above but works similarly https://paste.mod.gg/aiikrzhatitn/0;

#

not that I'd recommend you to do it that exact same way, but this should helpfully get you started.

visual stag
#

why are you doing _ = everywhere?

#

Also, it should be intValue, not enumValueFlag

gloomy chasm
#

Yeah... why are you? Just to indicate that it returns a value?

waxen sandal
#

Wrong channel

#

Go ask tabnine for help

whole steppe
whole steppe
humble walrus
#

I'm trying to make an attribute that shows the property if a condition is true, so i did:

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (isConditionTrue(property))
        {
            EditorGUI.PropertyField(position, property, label);
        }
    }

to show the property, it works for things like bool, string etc. But for list it only hides the elements and not the label etc.

whole steppe
#

I'd use the EditorGUILayout.BeginFadeGroup() method like this:

if (EditorGUILayout.BeginFadeGroup(isConditionTrue(property) ? 1F : 0F))
{
    EditorGUI.PropertyField(position, property, label);
}

EditorGUILayout.EndFadeGroup();```which *should* work as you're expecting in your case, could also make the check method return the float directly too.
visual stag
#

Property drawers only affect elements, not collections. There is no way to do what you're looking for without a custom editor, or an asset that implements one for its attributes

whole steppe
#

and apparently the EditorGUILayout class (is) => isn't meant to be used in a PropertyDrawer... so please ignore the above suggestion of mine.

blazing juniper
#

if I know a couple of scripts are always gonna be on the same object would implementing an interface in an OnEnable function in the editors of each script to Get the other components a bad idea
IE an IGetRequiredComponents<T> thing (I'm not even sure if this is possible)

I know I could have a public function and drag and drop or do stuff on start but I'm getting into editor stuff and need the references in the editor and want a foolproof way that in the future everything will have the stuff it needs
basically make it idiot proof so me and anyone working on this project can focus on other stuff instead of sorting out dependencies

whole steppe
#

but<T>

blazing juniper
#

sorry been at it for a couple hours hahaha didn't realize my brain was putty till now. my b

gloomy chasm
whole steppe
gloomy chasm
whole steppe
#

butt

timid whale
#

Repost from ui-toolkit text channel.

CreateInspectorGUI is being called every editor frame for the Inspector, during UnityEditor.RetainedMode.UpdateSchedulers(). This causes massive lag. Anyone encountered this yet?

Unity 2022.2.1f1

brazen frigate
#

I wanted to know how to install Netcode without the unity package manager. Someone pls help me

obtuse plover
#

So i got a quick question. I'm working on some editor tools for 2019.4 (VRChat specific tools.) and i've noticed that when I run a longer running async task that it completes significantly faster in play mode than it does in Edit mode... been googling for a day or two now to try and find the cause and or solution to this but no luck so far, anyone have an idea why this might be the case?

(simple Async method using Task.Yield())

For some reason running that method in Edit mode takes ~6 seconds.
but when I run it in play mode it suddenly completes in like ~3 seconds.

it's not really crucial but I'm highly curious why there's such a significant speed difference here.

#

that's edit mode vs playmode.

gloomy chasm
obtuse plover
#

which while sensible. is a shame in my case

gloomy chasm
obtuse plover
#

only other method i found to achieve what i'm working on is currently impossible because of bugs in the version that i'm working in but i'm locked into this version considering what i'm making the tools for.

#

so slow mode it is i guess

gloomy chasm
obtuse plover
#

the async is on purpose to visualize the process of what it's doing. it's mostly for debugging/flair. if i run this synchronous it runs sub 0ms lol. it's mostly a curiosity thing then a problem really.

gloomy chasm
#

Ah, I would probably do it as a coroutine then maybe?

obtuse plover
#

keep running into wierd rendering related issues with unity tho.

#

namely that Graphics.DrawMesh (and it's variants) and any form of line drawing utilties all remain until the editor is refocused rather than per frame like they are supposed to. they work fine per frame in play mode. but the second you use any of them in edit mode it results in wierd duplicating behaviour

obtuse plover
#

the bug is that these functions are supposed to draw their output for 1 frame. yet for some reason they stay much longer then that. causing dozens of duplicate meshes. only in edit mode. the second you go to play mode it works perfectly.

gloomy chasm
obtuse plover
#

the Debug and Handles line tools have the same problem. that where they're supposed to draw something for 1 frame, their output stays indefinitely

obtuse plover
gloomy chasm
obtuse plover
#

yes.

gloomy chasm
#

How are you repainting?

obtuse plover
#

I've tried:
Sceneview.RepaintAll();
Sceneview.LastActiveScene.Repaint();

and a few other ways i found online but i've forgotten at this time.

gloomy chasm
#

Where are you drawing from?

obtuse plover
#

currently SceneView.DuringSceneGui because i'm using Handles.DrawLine at this point as it's the only one that does properly erase in this usecase. the problem with it is that handles is not really optimized for the amount of things i'm displaying here so it's causing a very notable drop in framerate.

i've also tried a few others but same as above.

gloomy chasm
obtuse plover
#

to give an example of what's happening

#

this is a quick example using Debug.DrawLine but it's the same issue

#

all of these lines were drawn individually one at a time. the scene is repainted between every line manually. yet for some reason all the lines stay.

#

the second i go to playmode tho it does always display only 1 line at a time.

gloomy chasm
#

Can you share the code?

obtuse plover
#

sadly i no longer have the code for the graphics part. already threw that out yesterday cuz i couldn't get it working

gloomy chasm
#

Haha, how it goes

obtuse plover
#

as for the little yellow line render test there

        public static async void DrawTest(GameObject target) {
            foreach (SkinnedMeshRenderer renderer in target.GetComponentsInChildren<SkinnedMeshRenderer>()) {
                Vector3 vA = Vector3.zero;
                Vector3 vB = Vector3.zero;
                for (int i = 0; i < renderer.sharedMesh.vertices.Length; i++) {
                    vA = renderer.sharedMesh.vertices[i];
                    if (i + 1 < renderer.sharedMesh.vertices.Length) vB = renderer.sharedMesh.vertices[i + 1];
                    Debug.DrawLine(vA, vB, Color.yellow);
                    SceneView.lastActiveSceneView.Repaint();
                    //or SceneView.RepaintAll();
                    await Task.Yield();
                }
            }
        }
#

this was just a quick cruddy way of setting up an example with what i had at hand lol

#

single line segment zipping around rapidly

#

for some reason it's like it's buffering all these things and just never discarding them.

#

and apparently this has been an issue since 2011 already.

gloomy chasm
#

huh, I see what you mean

obtuse plover
#

and the Graphics. functions suffer from this same problem. where drawing in edit mode never erases the previous frame. it just remains indefinitely until something causes a proper refresh (tabbing out of unity and back in causes it to clear up properly)

#

but when you're using it to draw an overlay, rapidly stacking a mesh like that just murders the framerate.

#

starting to think my best options is gonna end up being just instantiating an object in the scene and modifying that.. will likely end up being more reliable that way.

#

tho i had hoped not to cuz it's probably gonna get in the way of things since it'd become a clickable object.

gloomy chasm
#

You could probably get what you want by having a field with the current index, and draw at index, set index to next, repaint, return. Instead of doing async stuff

obtuse plover
#

you made me realize something but it's gonna need some testing to double check that..

#

could very well be that the quick/dirty async trick is that's causing the issue in the first place

#

since it's kind of a hacky way of doing things..

gloomy chasm
obtuse plover
#

nope.

public static void DrawTest(GameObject target) {
            SkinnedMeshRenderer renderer = target.GetComponentInChildren<SkinnedMeshRenderer>();
            Vector3 vA = renderer.sharedMesh.vertices[vertI];
            Vector3 vB = renderer.sharedMesh.vertices[0];
            vertI++;
            if (vertI + 1 < renderer.sharedMesh.vertices.Length) vB = renderer.sharedMesh.vertices[vertI + 1];
            else vertI = 0;
            Debug.DrawLine(vA, vB, Color.yellow);
        }
``` even with proper non async code it has the same issue,
#

that still only draws 1 line segment per 'frame' they still all stay behind.

#

glad to know it's not the async trick at least.

#

it got the zoomies in playmode tho. lol

#

i did however notice that this does solve 1 issue i had before..

#

the refresh rate this way seems to be the same rate as in play mode at least.. which fixes the very first issue i was talking about. where for some reason the async function ran much slower in play mode then it does in edit mode.

#

seems i got a few methods to refactor.

obtuse plover
ripe kite
#

Does anyone have a technique for getting an editor callback (i.e. not playmode) when you attach a child object to a parent object? Ideally I'd want to define the callback on the child object.

OnValidate kind of works, but it seems to get called a lot, including on side threads and at runtime. If I went that route, I'd want to figure out a way to filter out the false positives.

ripe kite
ripe kite
#

Looks like OnTransform[Children|Parent]Changed requires ExecuteInEditMode. For my use case, I could probably just use Awake if we're doing execute-in-edit mode.

I think I'll keep poking around, since I'm hoping to avoid adding that attribute to anything that isn't purely visual.

ripe kite
#

Nice, that's also really useful.

I'm not sure if this will shake out in the long run, but the pattern I'm going for right now is basically OnValidate() with an editor-only guard condition for stuff I only want in the editor. It means that there will be redundant processing (i.e. not just when the parenting occurs), but for this use case I might be able to write the logic so that it's valid to run at any time within the editor itself.

jovial plaza
#

Hi Folks, I'm trying to figure out how to do serialization with SerializedProperty and serializedObject. I've got a custom editor TrackMarkerEditor with a target type of TrackMarkerManager.

This TrackMarkerManager has a SerialisedField of type TrackMarkerScriptableObject which contains a list of points around a racing track (i.e. [SerializeField] public List<Vector3> trackMarkers;

I'm not sure how to get the serialised object from the scriptable object when I'm in the Editor. This is what I'm trying at the moment, but the. trackMarkers (SerialisedProperty) is null

private void OnEnable()
        {
            TrackMarkerManager trackMarkerManager = (TrackMarkerManager) target;
            trackMarkers = serializedObject.FindProperty("trackMarkers");
            Debug.Log(trackMarkers);
            trackMarkerManager.Initialise();
        }

Any ideas what I could be doing wrong?

gloomy chasm
#
var trackmarkerProperty = serializedObject.FindProperty("TrackMarkerScriptableObject");
using (var trackMarkerSerializedObject = new SerializedObject(trackmarkerProperty.objectReferenceValue))
{
  var trackMarkerers = trackMarkerSerializedObject.FindProperty("trackMarkers");
            Debug.Log(trackMarkers);
}
jovial plaza
#

@gloomy chasm Aha! I understand how it works now from your code :). I've managed to get it working now :). Thanks!

#

@gloomy chasm I'll need to use trackMarkerSerializedObject.ApplyModifiedProperties(); when the trackMarkers are modified in order to enable undo/redo?

gloomy chasm
#

Simply before the end of the using block

frozen perch
#

Hiya,I would like to make a box that loops through the sprites that are asigned in the fields above it. Any idea how I can achieve this?

frozen perch
#

I think I might've found a package to help with this: Editor Coroutines. Just gotta make sure they disable everything when the editor in question is not in focus

frozen perch
#

Basically, I want an animation to show in the big gray square, and the animation is looping through the sprites I assign in the Idle Animation list.

#

I managed to get EditorCoroutines to work nicely, and figured out how to access the data of the monobehavior (i.e. the "target") that this is linked to

#

I am currently struggling to get a link to the uxml element though 😐

frozen perch
#

it's still not polished, but this is what I wanted to achieve 😄

gloomy chasm
jovial plaza
#

Hi Folks, is there a way to stop my gameobject that I am currently editing being deselected when I shift+click (to add another point on my racing track)? I tried to e.Use(); but it doesn't seem to stop propagation of the event

gloomy chasm
tacit kiln
jovial plaza
# gloomy chasm Gotta `.Use()` the mouse up event

Sorry just getting to try this now, can you think of any reason why the MouseUp event wouldn't be fired? I never get this LogError message

private void HandleInputEvents(TrackMarkerManager trackMarkerManager)
        {
            var e = Event.current;
            int controlID = GUIUtility.GetControlID(FocusType.Passive);
            var eventType = e.GetTypeForControl(controlID);

            if (eventType == EventType.MouseDown)
            {
                HandleMouseClickInput(trackMarkerManager, e);
            }

            if (eventType == EventType.KeyDown)
            {
                HandleKeyboardEvents(trackMarkerManager, e);
            }

            if (eventType == EventType.MouseUp)
            {
                Debug.LogError("MouseUp");
                e.Use();
            }
        }
whole steppe
#

nooo

weak lotus
#

Test scripts not showing in the test runner. Although I have added test scripts in a folder with its assembly definition. Any guidance ?

whole steppe
#

have been creating 131072 animation clips since yesterday using the AssetDatabase.CreateAsset() method, it started off pretty fast, but then begun to slow down as time passes, it just keeps getting slower and slower, I thought maybe if I kill the task and restart from the last one created, it would be fast again in the beginning, but nah, still pretty slow... any idea what else can be done?

whole steppe
#

just to make sure because my example is in a loop, does this look right?```cs
for (int i = 0; i < length; i++)
{
if (!File.Exists(path))
{
AnimationClip clip = new AnimationClip();

    clip.SetCurve(relativePath, typeof(MeshRenderer), $"material.{propertyName}", AnimationCurve.Constant(0F, 0F, 0F));

    try
    {
        AssetDatabase.StartAssetEditing();

        AssetDatabase.CreateAsset(clip, path);
    }
    finally
    {
        AssetDatabase.StopAssetEditing();
    }
}

}```or maybe I should have the SetCurve() method inside the try block?

visual stag
#

that's doing nothing. The point is to wrap all your calls in one block

#

so they are batched together

#

put the entire loop in the block

whole steppe
#

oh! alright! I'll do that!

visual stag
#

also, what's the point of creating all these identical assets. Presumably your code doesn't look like this?

whole steppe
#

and if I understood anything from this conversation, this means I'd need to wrap not this loop, but the very first loop in the method where all the other loops are nested inside of it, because the loop in the above example is the final loop and doesn't determine the total amount of creations.

visual stag
#

Sure, whatever has all the AssetDatabase calls in it that you want to batch together

topaz imp
#

hi guys, I'm trying to register a callback for the mousedownevent on the rootVisualElement but it never trigger

#

I'm drawing a grid as the editor background and I want to move it when I drag with the mouse

dusk mason
#

is it possible to change these icons?

gloomy chasm
gloomy chasm
topaz imp
#

@gloomy chasm ah interesting, and where would I draw the line at every re render of the ui ?

gloomy chasm
topaz imp
#

I'm using 2021.1, I'm using handles

#

but my question was more about should I pick one of those two methods and do the drawing there ?

gloomy chasm
#

Well idk what you are doing so can't really say

topaz imp
#

thank you, I will read the documentation for the methods, unfortunately I didn't find a nice overview of these concepts, I didn't know this two methods were not supposed to be used together

gloomy chasm
# topaz imp thank you, I will read the documentation for the methods, unfortunately I didn't...

Unity has 2 UI systems. Immediate Mode GUI (IMGUI) which redraws the whole UI 'every frame'. It uses the OnGUI method, and the GUI, GUILayout, EditorGUI, and EditorGUILayout classes.
The other newer UI system is UIToolkit (UITK), it works by building a structure of elements and only redrawing specific elements when things change on those elements. The type of UI is called a retained mode GUI.

topaz imp
#

thank you, very helpful

#

just out of curiosity, way is it possible to mix these methods ?

gloomy chasm
#

You can use a IMGUIContainer if you want to use IMGUI within UIToolkit, but if you can help it, it is better to do it within UIToolkit instead

topaz imp
#

no, I mean, why is it possible to define an ongui method on a class inheriting from EditorWindow and having the imgui system stepping in

#

but I guess your last sentence says why

gloomy chasm
#

Do you mean how?

topaz imp
#

yeah, I mean, why they decide for this to be possible, instead of making these libraries in a way they couldn't interact with one another

#

you can only pick one

#

but I imagine they might be using reflection on the classes under the folder Editor

#

instead of like a plugin system based on types

gloomy chasm
#

Ah, because you still need basically everything else on the EditorWindow, and the OnEnable, OnGUI, Awake, etc. methods are 'special' Unity methods that it finds simply by their name. So there isn't really a way to restrict the user.
The only other way is if they instead had a base EditorWindow class and two subclasses, one for IMGUI and one for UIToolkit, but doing that would break every editor window anyone has ever made since the EditorWindow class would no longer be able to have the OnGUI method.

#

So instead, they just have an option to use one or the other

topaz imp
#

I see, thank you, very helpful

#

this clarified lot of doubts

gloomy chasm
#

Glad I could help