#↕️┃editor-extensions

1 messages · Page 2 of 1

gloomy chasm
#

That is because your scripts are not in an Editor folder

balmy cliff
#

I have a Prefab Base, with BaseComponent.cs attached. I want to also have a Prefab Variant with SubclassComponent.cs attached. Is there a way to do that without breaking the connection? In other words, any way to avoid this outcome on the prefab variant?

gloomy chasm
balmy cliff
#

kind of a bummer, since it almost works if you switch to debug view and swap the components.

sour pollen
#

no idea if right section, but me and my teammates developed this tool for prefab-making of player enemies 2000 BC

#

question... any way to force point filter (nearest neighbor scaling) to that preview?

#

its a 16px

#

so it becomes ugly

waxen sandal
#

Probably gotta pass a material to the method

slim seal
#

I do not know in which channel I can ask exactly this question, so I will leave it here...

#

_ _
Due to the URP (Universal Render Pipeline) package, the window is not cleared at the beginning of the next frame from the previous render.

Full question with description and video of the problem:
https://docs.google.com/document/d/15Xj76NFJL_dKxzCo-UuFrc245kqE7vROYuaa5gVW12I/edit?usp=sharing

#

The question with a full description of the problem is very big, so I made a text document in Google Drive.

#

If I asked a question in the wrong channel, please let me know.

#

If necessary, I can send my full project via Google Drive. It weighs less than a gigabyte (maybe even less than 500 megabytes).

waxen sandal
#

Check your cameras clear mode

#

Idk how urp works but in normal unity it's just in the camera inspector

jade moth
#

Shieeet , Editor scripting is funnn .. it's like being in WPF all over again

peak bloom
#

UItk is fun, imgui isn't lol

visual stag
#

UITK is fun until you go off the beaten path and then it's like "oh, abstract internal method? fucka-you"

peak bloom
#

the api keeps getting better ♥️ ... although it still feels like not in production-ready state just yet

jade moth
short prawn
#

I'm using an Editor.OnPreviewGUI to display a model. The docs say the params of OnPreviewGUI are r - the rect for the preview, and background - a background image by way of a GUIStyle.

My problem is that no matter how I pass an image into the background parameter the background remains grey. I've tried creating a 1,1 texture and setting its pixel to a colour, I've tried passing in a texture, I've tried setting each background in onActive, onFocused, onHover, onNormal, normal to no avail.

I've seen other people override the OnPreviewGUI method and create custom previews to do this, but I've also definitely seen just the standard overload work.

I've just come to the realisation that all of the above is true in any SRP. But not using legacy. Works perfectly using legacy.

peak bloom
jade moth
#

well shit.. time to porting this newly made tool from today I guess 😣

peak bloom
#

yeah, it's not worth the time to use imgui for whatever reason... unless you're maintaining old games that tied to certain 3rd party library that can't used with latest Unity version

Tho, others may have their own opinion regarding this

#

Every now and then I still see job vacancies for making editor tooling with imgui, so that's another reason why you'd still want to use it I guess

short prawn
#

Probably because there's a shit load of stuff that is still undocumented, works poorly with UITK, or you literally have to cram custom shit down its throat to get it to work. There's a load of editor controls that still don't exist easily in UITK, and while the IMGUI container allows you to add custom IMGUI stuff it's only just barely functional.

peak bloom
short prawn
#

And quick, easy, feature bare tools you need to make in a day are still much quicker with imgui.

#

Currently my problem with UITK is that the entire editor goes to 1FPS whenever I'm editing a value in the inspector.

visual stag
next canopy
#

oh god it's been so long since I touched editor UI stuff. Is UITK the one that uses uss/xml?

visual stag
#

Yes ("UXML")

next canopy
#

pronounced ucksemell

#

There was something I wanted to make with that actually. Following the manual page on injecting into project settings

thin fractal
#

hey, hope everyone is doing great, i have to make tools in my editor and i wanted to know what is the depth of this extension, like how far can go in it and make stuff, any references or video tutorial would help thanks a lot

hoary grove
#

Drawing an Arc that scales with the transforms scale.

#

Is that possible?

gloomy jolt
#

This field has a custom attribute on it. But the OnGUI of that attribute doesn't get called untill I add entries to the list. How can I edit the Rigidbodies field even if the list is empty?

waxen sandal
#

You can't make propertydrawers for arrays

#

You can make a custom editor for the whole component if that helps

karmic ginkgo
#

i need to grab an imported gameobject (mesh) and set its import settings though a menu action

#

what i need speifically is a cast/conversion of the gameobject from asset db to importer type

#
ModelImporter importer = AssetImporter.GetAtPath(path) as ModelImporter;
gloomy jolt
#

@waxen sandal ok, thanks for the answer!

jade moth
stable crane
#

oh nevermind i was missing a generic bound : ScriptableObject

stable crane
#

when i do this, after i rename the asset it creates it loses the sprite data for some reason

#

also happens after entering play mode

visual stag
stable crane
#

oh yea i guess you can do that

visual stag
stable crane
#

ok yeah that works

#

ok yea nice thanks

mortal elm
#

Hi Team! im working on an Editor script to display positional vectors from structs in a list attached to an object. Im struggling to find how to get the index of the selected element so I can only display the 'highlighted' element

#

e.g. Element 1 is highlighted right now. I want to get that index.

mortal elm
#

From what I've read, it doesn't exist - if I want that I need to rebuild the entire inspector element and name the elements in the process, then I can access the assigned names.

peak bloom
#

it can be done, but I can't recommend you if it's imgui, I've been away from imgui for the longest time now 🙂
But if it's uitk, man, you can just blink your eyes, then poof! .. done..
All jokes aside, in uitk you can use ListView for this, and get the selected element/index via listView.selectedItem or listView.selectedIndex

mortal elm
#

im using 2020.3 which i think doesnt have uitk? - im making progressing doing the above, creating the list myself with names for the objects - but of a pain.

peak bloom
#

pretty sure it's available, but you don't have to use uitk, it was just my suggestion.. or just wait until other imgui masters that are knowledgeable answer your question

visual stag
#

For IMGUI you have to use ReorderableList, which is a bunch of work, but makes provides the selected index fairly easily.

mortal elm
#

Ahh yeah, cheers. Ive settled on just having a seperate list drawn afterwords where i can select a named element and have that highlighted. a little messy but saves me rebuilding the serialised list just to be able to have an onselect event

compact moon
#

What's the best way of handling user input in the editor?

subtle axle
#

Where should I save static variables from the editor? Just in a static class doesn't seem to survive me reloading my scene.

#

Is this a good use for Scriptable Objects? Or something else perhaps

gloomy chasm
subtle axle
#

Sorry if I'm asking this question wrong, but when working on a custom serializer, how do I get more fields to serialize under a list item?

subtle axle
#

I'm trying to custom serialize a list of an abstract class

#

I know I need to use ISerializeCallbackReceiever, and I understand the example they give. I've gotten to be able to make a list of strings of my abstract class name but don't know how to add the classes properties underneath it

gloomy chasm
subtle axle
#

SerializeReference doesn't seem to completely serialize the list though :/

#

It just says "Element 0" for example.

gloomy chasm
subtle axle
#

I'm trying to get the whole list editable

gloomy chasm
#

By default everything is serialized as a value which means they are automatically assigned a value.

#

But when serialized by reference, that means that they can references each other along with being null. So they default to being null.

#

That is why it says "Element 0". It is null

#

Does that makes sense @subtle axle?

subtle axle
#

Yeah, but I also can't "Drag and drop" a class to make an instance of it. I have this solved for one of my lists by creating a button and a dropdown to instance one of the classes in a list

#

But how can I add to the list, and choose which class to add to it so it doesn't do that?

gloomy chasm
subtle axle
#

I have Odin. Which works great. But I am trying to turn this into an asset so trying to code this bad boy myself.

#

It seems like you should be able to drag a script from the editor onto the list to do that :/ or something along those lines.

#

How can I hijack the "+" button to create a property drawer?

gloomy chasm
gloomy chasm
#

I would just create a property drawer for the base abstract class that has a dropdown for selecting the type

subtle axle
#

So what are my options? Like I said, I've done this for a list that lives on my item, but this other list I'm trying to do it with is a few variables deep LOL

#

Would that make it so when you add to the list it shows that property drawer?

subtle axle
#

Okay so if on "Game Item A" I have a list of "Abstract Class B", and Classes C and D are children of that class, I'd add a property drawer to "Abstract Class B", then when I add a new item to "Game Item A" it'd give the ability to add Classes C or D?

#

Am I understanding that correctly?

gloomy chasm
#

@subtle axle super scuffed semi-pseudo code

[CustomPropertyDrawer(typeof(MyClass))]
class MyClassPropertyDrawer :PropertyDrawer
{
  override void OnPropertyGUI(SP property, Rect rect, GUILabel label)
  {
    // We get a rect for the dropdown field that is a single line height.
    Rect dropdownRect = rect;
    dropdownRect.height = singleLineHeight;
    
    // Draw a button that looks like a dropdown.
    if (EditorGUI.DropdownButton(dropdownRect, "Type"))
    {
      // Get all the types that derive from the field type of the property.
      // This will be "MyClass". Instead of "property.managedReferenceType", you could also do "typeof(MyType)". Might actually be better tbh.
      var types = TypeCache.GetDerivedTypes(property.managedReferenceType);

      // We create a menu, and add an item for each type we could create.
      GenericMenu menu = new GenericMenu();
      foreach(var type in types)
      {
        // NOTE: you will want to do a check to see if the type is not abstract before adding the menu item for it.

        // We create a menu itme, and if it is selected we assing the "managedReferenceValue" to a new instance of the type using "Activator.CreateInstance(..)".
        menu.AddItem(type.Name, obj => property.managedReferenceValue = Activator.CreateInstance((Type)obj), type);
      }

      menu.ShowDropdown(dropdownRect);
    }
    
    Rect fieldRect = rect;
    fieldRect.y += 21;
    // Calling PropertyField for the property will (if memory serves) call the base drawer as if it was not drawn with this custom property drawer. This results in the dropdown field and then the property drawing normally below it.
    EditorGUI.PropertyField(fieldRect, property);
  }
}
#

But that is basically what you would do

subtle axle
#

Thanks, I'll have to take a look at that. At first glance that's a bit over my head, but thank you!

#

It looks like that ovverrides the base PropertyDrawer, is that correct? Is this just adding functionality to it?

gloomy chasm
subtle axle
#

Oh, I just TOTALLY missed that top line. Thanks

gloomy chasm
subtle axle
#

Haha, okay, it's amazing what that one like did to jog my memory. So this is similar to adding a custom inspector window.

#

Okay so I know you meant it as psuedocode and didn't test. I'm getting errors on the types "SP" and "GUILabel", usually it gives me the ability to add the "Using X", but I'm not getting that this time.

gloomy chasm
subtle axle
#

Nah you're fine I can play around with it

gloomy chasm
#

Like "SP" is SerializedProperty

subtle axle
#

Do you know, is OnPropertyGUI the right method? Can't find the API reference for it

#

If I could find the method, I could find the type for example

gloomy chasm
#

it should be something close to that

subtle axle
#

Create Property GUI? Or OnGUI?

gloomy chasm
#

OnGUI

#

I added some comments to try and help explain the code

subtle axle
#

Thank you

#

What will the singleLineHeight be?

#

Sorry I'm just kinda going line by line...Appreciate your help on this. What should I reaplce "Type" with?

gloomy chasm
gloomy chasm
#

Oh you mean "Type"

#

That is just what text the dropdown button should display

#

It can be anything

subtle axle
#

Thanks so much. The last error I'm getting is when I try to use the dropdown (which works btw to get the right types)

#

InvalidOperationException: Attempting to set the managed reference value on a SerializedProperty that is set to a 'PPtr<$ActionResponse>'

#

ActionResponse is the "Myclass"

#

the error is on that menu.additem line

#

I think I got that error taken care of. The dropdown works, but it won't actually select anything :/

mild bobcat
#

I have custom inspector and i'm using serializedObject to test for multi-object editing. It works but when I enter playmode and then leave playmode and have a gameobject with my component with the custom inspector (and then try saving) I get this error SerializedObjectNotCreatableException: Object at index 0 is null. I've google and googled and can't find a solution. What I find on google is people saying it's a "2nd" inspector causing it but I have no 2nd one open. Restarting unity doesn't work either.

rotund laurel
#

Can I get the orientation of the preview camera used in Editor.OnInteractivePreviewGUI()? I'd like to be able to use this preview to orient an object and then take a snapshot of it

subtle axle
#

Hey, any idea why this line "property.managedReferenceValue = Activator.CreateInstance((Type)obj);" in a custom drawer wouldn't actually create a new instance of type obj? There's no error being thrown but when I select anything in the dropdown, nothing happens.

fickle comet
#

is there ANY way of getting the active path in the Project window?

stark geyser
subtle axle
#

Here I have a custom property drawer. I'm trying to make it so a previously unserializable class can become serializable. The dropdown works, but when I actually choose one of the dropdown items nothing happens. There's no error though.

tough cairn
#

any ideas how can i add an item in this list with a script ?

#

tried searching ProjectSettings folder but doesn't seem like the Script Execution Order data is being stored there

tough cairn
#

i think i found it :

UnityEditor.MonoImporter.SetExecutionOrder( UnityEditor.MonoScript.FromMonoBehaviour(_instance), 0 );
subtle axle
gloomy chasm
subtle axle
#

@gloomy chasm So the dropdown shows all of my ActionResponses. But when I click a dropdown item, nothing (seemingly) happens in the inspector. The debug log shows me that indeed the managedreferencevalue is changing, but in the inspector it still just says "Element x"

gloomy chasm
subtle axle
#

Yes, it is! I'll do that and let you know the result.

#

@gloomy chasm So within that callback function, it's working. Within the OnGUI, it's null.

#

by working, I mean its set. It's not working, per se

gloomy chasm
subtle axle
#

Is that a method of the property?

gloomy chasm
#

property.serializedObject.ApplyModifiedProperties()

subtle axle
#

Still null 😦

gloomy chasm
#

Where did you put it?

subtle axle
#

`
void CreateActionResponse(object obj, SerializedProperty property)
{
Debug.Log(property.managedReferenceValue);
Debug.Log("You have selected " + obj);
property.managedReferenceValue = Activator.CreateInstance((Type)obj);
Debug.Log(property.managedReferenceValue);
property.serializedObject.ApplyModifiedProperties();

}

`

#

Hey I'm sorry

#

It did overwrite

#

I think something happened when I saved

#

Okay, so it is now saving the variable, but nothing is happening within the inspector.

#

It's definitely doing something now. It added a dropdown arrow to the element, but still doesn't seem to quite be serializing it.

subtle axle
#

Sorry, I'm really not trying to keep bumping but I want this info to be as up-to-date as possible if people do decide to help. Messing around with [Serializefield] and reference, I got it so it'll change the list name to be the correct actionresponse. My biggest problem is no children properties of that class show up in the inspector.

gloomy chasm
subtle axle
#

Sure!

#

@gloomy chasm I had it at one point saying the name of the ActionResponse instead of Element but somehow I screwed that up in messing with [SerializeField] and [SerializeReference]

gloomy chasm
#

And have it return return EditorGUI.GetPropertyHeight(property) + EditorGUIUtility.singleLineHeight;

subtle axle
#

Okay! Here, I'm going to DM you some of the other classes at play if that'd be helpful

#

Override propertyheight in that drawer class?

gloomy chasm
subtle axle
#

Hm. That definitely adds more space! So thanks for that, but it's still blank :/

visual stag
#

you will need to do the same for GetPropertyHeight

wintry trout
#

Why don't I get a slider?

visual stag
wintry trout
#

nope

#

gonna try

wintry trout
waxen sandal
#

Sliders fallback to an input field if there's not enough space

oak dragon
#

Can't really find the perfect channel to ask this question, but I think it is most relevant to this one. Say I'm making an asset for the asset store, should I include preview packages as dependencies? Or should I try to avoid that as much as possible. I'm thinking of using jobs and boost for multithreading, but I am worried people won't want to use the asset because of the dependencies.

slate cliff
#

Any idea why I can only drag one GUI.Window if I have multiple open? They all have separate IDs...

#

All I'm doing is calling GUI.DragWindow at the very end off my GUI.Window draw callback

#

One window has ID 0 and the other one has ID 3852

thin fractal
#

hey guys, i am making some tools in the editor and i have a dropdown of a Enum in the inspector right now and when the dev selects a enum i want more options to appear in the inspector for further configuration. how can i do that?

waxen sandal
#

Custom editor that checks the value of the property and then draws different fields based on that

full badge
#

How do I make these expandable groups like in the URP render asset?

#

is it a built in feature or do i have to make it myself?

waxen sandal
#

Foldout?

hardy ore
#

how do i get these?

hardy ore
#

oh i thought it was an extension for visual code so i asked here

tight python
hardy ore
#

cool

#

if i change the external tool thing does it just work??

tight python
#

It should just work. Yeah. You might need to re-start your Visual Studio not 100% sure tho.

wintry trout
#

What does SerializedProperty.Update exactly do?

#

There is such an explanation

Update = set serialized object stream now based on what is in the actual class

ApplyModifiedProperties = take what is in the object stream and put it in the class 

But it is pretty unclear to me

#

Like what is the actual class

#

and what is the object stream

wintry trout
#

I have a list inside a struct. Am making a custom property drawer for the struct. How do I find out which exact element of the list was changed, if any?

wintry trout
#

Why do I get this?

gloomy chasm
wintry trout
#

Changed it, now the button is still over the component

gloomy chasm
wintry trout
#

How should I override it?

#

Also I meant the Add Component button

gloomy chasm
wintry trout
#

Oh, it is used by Inspector itself while producing the button?

#

????

gloomy chasm
#

No, it is used by the inspector when drawing the property to know how much space it takes up

#

Thus the name, Get Property Height

#

Gets the height of the property

wintry trout
#

Well it is what I meant

#

Thank you

wintry trout
#

Well, now when I collapse and expand the list the the button adjusts its position only when I hover some other element

#

Any advice?

#

(the 2 last ones are with correct placement)

gloomy chasm
wintry trout
#

Gonna sleep btw

gloomy chasm
# wintry trout So what do I do?

You get the heights in the GetPropertyHeight method instead. Or simply use EditorGUIUtility.singleLineHeight and EditorGUIUtility.standardVerticalSpacing

wintry trout
waxen sandal
#

Don't cache your height

#

You have to recalculate it in GetPropertyHeight

wintry trout
waxen sandal
#

No you're not

#

Don't just find them, use them

#

What's happening, it's drawing and calculating height, caching that height

#

It stops drawing but is still asked for the height, the cache is never updated and thus it uses the height from the last draw

#

At least, that's what I'm guessing

wintry trout
#

But it recalculates every time

waxen sandal
#

Every OnGUI it does, but OnGUI isn't called when it's not drawing

wintry trout
#

1 sec

waxen sandal
#

So remove that field on your class and make it a local field

#

Yeah there's no call to GetPropertyHeight for those relative properties here

wintry trout
#

How are there not

#

I see them on this screenshot

waxen sandal
#

There's on FindPropertyRelative

#

No there's not

wintry trout
#

Omg

#

Did wrong thing again

#

Thank you

wintry trout
#

So method stops and the inspector isn't drawn at all

#

Now I have this code which works but with bad results

#

Okay solved it myself

#

Thank you all

knotty cave
#

I don't think this belongs here, but is there any Editor extension that adds the capability of the inspector to change tuple and struct values of a MonoBehaviour instance?

gloomy chasm
knotty cave
#

Ah, thank you

zealous ice
#

Hey, small yet substantial question or rather questions:

  1. Do you know an asset that would allow me to append a build version to my project based of git tags
  2. If not, do any of you know how to sneak a string or two into build in a way that won't disrupt the project itself?
#

One approach for the latter is just adding a txt next to the exe (in the post build callback) and working with that, but it feels... ugly

zealous ice
#

Command line argument? No?

#

Basically I want to have something like that in my game but nicely automated based of git

dreamy lava
#

you can run unity with command line (ex: "C:\Program Files (x86)\Unity\Editor\Unity.exe" -projectPath "C:\Projects\svn_repos")

dreamy lava
#

the version is given by the build property right ?

zealous ice
#

What build property you have in mind?

zealous ice
#

Yeah, considered using that as a way to keep the version

#

But it has the issue of adding changes to git when I build a game

dreamy lava
#

then i'm not sure to understand your purpose ^^

zealous ice
#

Okay, let's say I have a git like so:

A - B - C - D

and tag v0.3.5 on the commit B

#

Now, D is two commits ahead, so when I build. I will get a version like:

v0.3.5.2-commithash
```added to the build
#

Without altering the project settings nor files

#

I then add a commit E, with a tag v0.4.0 because I've added some feature

#

Now, when I build I will get a version like

v0.4.0.0
#

Which I will then be able to get in my code and display in UI

#

While I editor I can just ask the git for that number, in build I have to somehow inject it in

#

Altering Application.version will however add a change to git, which I don't want as that will be a tad messy

dreamy lava
#

i get you

zealous ice
#

Unless I can, I don't know, set the .version and then set it back so it's not visible in the repo?

#

But that might cause troubles on something like android which requires sematic versioning (I might be wrong on that) so it will be angry that Application.version has letter and stuff

dreamy lava
#

i think you have to create a custom BuildPipeline where you manage to retrieve your git versions, then you are right you could have issue with mobile deployment (i'm not sure but propably). So better to override the Application.version. If this build Buildpipeline is integrated in a CI pipeline, it will be called by CLI or watever. So it will build your project without saving anything, and without changing the source files at the end

zealous ice
#

Well, but changing .version like that will cause commits on git if I build from editor, which I do

dreamy lava
#

then build with CLI :p

zealous ice
#

you could have issue with mobile deployment (i'm not sure but propably). So better to override the Application.version
Well, I am more worried that overriding it will cause issues on mobile

#

But that's another step to my build I need to remember

#

Application.version is read only...

#

What?

#

Ah right, PlayerSettings.bundleVersion

#

Which apparently unlike the docs say, is not for Android and iOS only

#

I might try it later

zealous ice
#

@dreamy lava// Yeah, android allows only numbers and dots in the bundle version

silver wave
#

**Conceptual question **: Dropping the txt version of this question around Editor Tools development so you can just expand it in the discord. Didn't want to post the massive text wall.

timid coyote
#

is it possible to replace the flag name field with a drop down in a custom editor? Ive tried a property drawer but i dont know how i can maintain the rest of the fields intact, and only modify flag name. (i need to get the array for the drop down from flags data)

gloomy chasm
silver wave
gloomy chasm
silver wave
gloomy chasm
gloomy chasm
#

Of course there are times where it is better not to use them. Like with anything, moderation is key 🙂

silver wave
#

Hahaha indeed. Appreciate the detail/advice bud. Will post a git when I solve this and ping ya if you're interested. Feels like I'm actually on the verge of finally making something remotely useful

gloomy chasm
#

Nice! Good luck! 😄

whole steppe
#

Okay big mistake that project is 5 years sitting idle. Ignore me. I'll try to find some guide on how I can add a project to source control.

visual stag
whole steppe
whole steppe
#

nice thanks

restive sierra
#

Hello everybody, is it possible that the Script of a ScriptableSingleton is already an instance of ScriptableSingleton? When i create ScriptableSingleton Object it seems this is another instance of the ScriptableSingleton. I am confused about ScriptableSingleton, getting an Error when clicking on the ScriptableSingleton Object -> ScriptableSingleton already exists. Did you query the singleton in a constructor?

timid coyote
full badge
#

I got a property drawer that changes in size depending on an enum field. How would I go about setting the property height to the right value?

#

I got it working but now my input fields are thicc

gloomy chasm
full badge
#

yeah i did that

#

but now i got another issue

gloomy chasm
tepid barn
#

Whats the best way to resize a Texture2D so it fills the entire of a
GUILayout.Box? I know GUI.DrawTexture has a ScaleMode.ScaleToFit property, is there anything similar for GUILayout.Box?

stable crane
#

is there any way to get the type T in a custom property drawer for a generic class?

#

for example

#

something like this although obviously that doesnt work

#

or atleast the name of the T generic type

#

what i want is a field where i can do something like AnyInstanceOf<AttackPattern>

#

where AttackPattern is an abstract class

#

but i get a choice to put anything that derives from it in that field

#

i know how to do that just thought it might be possible with a generic so i dont have to duplicate code since i will use this for a few different things

gloomy chasm
stable crane
#

fieldInfo.FieldType.GetGenericArguments()[0] but yeah thats it thanks

#

i cant seem to be able to access this though

#

FindPropertyRelative("value") returns null

#

oh nevermind

#

forgot SerializeField

#

well in mycase SerializeReference

#

ok this is beautiful

stable crane
#

made it better with an attribute instead

#

one thing thats annoying me is that using GUILayoutUtility.LabelWidth makes this 2 pixels too big

gloomy chasm
stable crane
#

yea

#

just find it weird

#

although i guess its intended that you use a padding of 2 pixels maybe

thin fractal
#

hi can anyone help me with this editor problem that I am facing, It is really hard for me to explain as well but I will try my best, I have a class "Action" which has different types as well, For example, Action A, Action B, Action C. When a certain action is selected from the enum dropdown it shows the properties of that action in the inspector. for example if Action A is selected, it will show properties relevent to

#

Action A

#

And i want a list of actions on a scriptable object lets say i have a list, which has 10 actions on it of different types

#

Action A, Action B ...... and so on

#

these can repeat as well there can be 5 action A in one list and 3 action B

#

and all their specfic properties are visible as well

#

and these all execute in a sequence but this part i can do i just want to know how do i get a list of Actions and select an action type in inspector and show relevent properties and edit them in editor

thin fractal
# stable crane

sort of like this but the properties draws after a type is selected in the inspector and i can have a list of these and the properties draws in the list too

stable crane
#

make it not an enum

#

but a derived class instead

#

have class Action

#

and then ActionA : Action

#

then have a field of type Action

#

that can take any of them

#

and put their respective properties into fhe class definition

peak bloom
#

👆 also, SerializedReference sounds perfect for this 🙂

stable crane
#

wrote a blog post about this, feel free to use the code. I also explain how it works in case you want to modify it a bit

west drum
#

While my problem is not really an "editor-extension" issue, it is quite related to the editor, so I thought maybe you could give me a hand with it. I have this error popping up in the console during development.

#

The class is really so simple... I have no idea how could it be possible to give any kind of issue...

waxen sandal
#

Show the captain type

west drum
#

It is an ScriptableObject

unique violet
#

is there a way to reload all assets for a specific scriptedImporter?
ex: I have a custom ScriptedImporter for "data" files, and I want it to run for all .data files when I click a button in the editor.

weak spoke
unique violet
glad pivot
#

how can i add a tooltip to a custom variable like in this editor? since this isnt working ofc

unique violet
worthy wyvern
#

EditorGUILayout.PropertyField(vector2) doesn't show up for me in a custom editor
the vector2 is a public property that I get through FindProperty
it also shows up correctly if I enable the base.OnInspectorGUI

EDIT: resolved, I was looking for an inexistent property

#

I hope this is the correct channel

thorny cape
#

Hey guys does anyone know how I can color the background so whenever a game runs its red / whatever color in the bg

visual stag
woven gull
#

Hey all, I have a pretty specific question about a custom property drawer. Unity's Animation Curve property drawer opens the Curve Editor window when you click on the property drawer, and when you edit the curve within that curve editor window, it updates the serialized AnimationCurve that is being drawn by the property drawer. I am trying to replicate that process. Here's what's done already.

  1. I made a custom editor window for a class I created.
  2. I've started writing a custom property drawer for that class. The property drawer, like the AnimationCurve editor, just draws some OpenGL stuff into a rect in the inspector. When the rect is clicked, it opens the Editor Window I created in step 1.

However, because the type sent to the property drawer is serialized, it sends a copy of the data to the window, not a reference, and so editing the type in the window won't be actually edit the actual field on the Monobehavior.

The data being edited in the window is is essentially a List<Keyframe>. How do I set the values of this this from the property drawer as the editor window updates them?

hushed owl
#

Is there a dirty way to make a table?

waxen sandal
#

In what?

worthy wyvern
#
serializedObject.FindProperty("PathTypeSelection").intValue = pathTypeSelection;
serializedObject.ApplyModifiedProperties();

this causes my Inspector to close whenever I change the pathTypeSelection value any property value

#

can it not do that

worthy wyvern
#

actually it's happening without that FindProperty

#

OK, I've restarted Unity and it's fixed UnityChanHuh

mossy iris
#

Hello guys, is there a way to separate big numbers with a coma or smth like this ? Maybe with an attribute ?

short venture
mossy iris
teal tinsel
#

Best place to put a project-wide and scene-wide settings for my package? It’d be great if I can add custom tab on project settings window 🤔

#

Ah I found SettingsProvider

stone hazel
#

Working on an editor and the scroll bar is staying fixed at top. It will not scroll down. This is how it is started off

#
        private void OnGUI()
        {


            EditorGUILayout.BeginScrollView(scrollPos);
hushed owl
#

Is there anyway to make this cleaner?

                if (genericLabelObjects.Any(x => x.Dirty))
                {
                    using (new EditorGUI.DisabledScope(hasUnsavedChanges))
                    {
                        hasUnsavedChanges = true;
                    }
                }
                else
                {
                    using (new EditorGUI.DisabledScope(hasUnsavedChanges))
                    {
                        hasUnsavedChanges = false;
                    }
                }
visual stag
hushed owl
#

How would I access the window scopes?

#

ffs this.hasUnsavedChanges = false;

#

Yeah?

visual stag
#

I don't know what you're asking

#

this is only required if you have a name that conflicts locally (or some other really specific cases)

hushed owl
#

this was my example of saying window.

visual stag
#

I have no idea what you mean by window scopes

hushed owl
#

Window is a window mate...

#

Anyways thanks for rubber ducky: hasUnsavedChanges = genericLabelObjects.Any(x => x.Filled);

visual stag
#

And your code and question makes no mention of that stuff, I'm just pointing out that the DisabledScope does nothing without editor controls to disable

hushed owl
visual stag
#

Huh, I've never used that property before

teal tinsel
#

How can I save my package's settings under ProjectSettings folder and access from there in runtime?
So I don't have to worry about user moving the settings around?
Why Unity doesn't support this with simple way? 😅

hushed owl
#

Question, please tell me there's a better way?:

if (genericLabelObjects[i].type == typeof(uint))
{
  int n;
  int.TryParse(genericLabelObjects[i].value, out n);
  genericLabelObjects[i].value = EditorGUILayout.IntField(new GUIContent(genericLabelObjects[i].key, $"{genericLabelObjects[i].type.Name}"), n).ToString();
teal tinsel
hushed owl
#

I was thinking a config file, that way you can handle any edits with any dir / file watch and just resolve to the new dir.

#

Watch the Projects settings?

teal tinsel
hushed owl
merry juniper
#

Hello how I can fix it

hushed owl
neon birch
#

Hi! I'm working on a custom MenuItem for the Assets/Create context menu. How would I get the name of the file on which the context menu was activated?

vapid seal
#

Hello, I have a quick question. II have a List<> of "Tech", the issue is that somehow one of the scriptable objects for "Tech" became corrupted? I think I might've deleted it by accident.

#

I'm trying to capture any nulls at the start of OnInspector, but it isn't working

#
 public override void OnInspectorGUI()
    {
        TechTree targetTree = (TechTree)target;

        for (int nodeIndex = 0; nodeIndex < targetTree.tree.Count; nodeIndex++)
        {
            //remove any weird null techs.
            if(targetTree.tree[nodeIndex].tech == null)
            {
                Debug.Log("NULL NODE");
                targetTree.tree.Remove(targetTree.tree[nodeIndex]);
                break;
            }
        }

short venture
vapid seal
#

I think I was messing up by trying to filter out the nulls at the editor as opposed to at the actual tech tree class

#

not 100% on the solution, but I think i'm getting there

hardy apex
#

My custom inspector called on OnInspectorGUI is updating the hierarchy many times per second. What is the best way for it to only update when the object in the scene updates, or when the inspector updates?

worldly ginkgo
#

Any ideas why unity would be refusing to link to script files in an 'Editor' folder, while in editor? Assembly-CSharp-Editor.csproj has the files listed, and UNITY_EDITOR appears to be defined... so I'm a bit stumped.

gloomy chasm
#

Think of it sort of like a MonoBehaviour's Update method

hardy apex
#

I've realized I can implement my intended behavior with a simple state machine (like what I'd do with an update loop in a monobehavior)
What would the correct syntax be for a static reference to an activeContext? I can't figure it out in the docs. Ie, Selection.activeContext == [SomeConstant]

short venture
hardy apex
#

I am not trying to set the active context, I'm trying to see if the active context is a specific context

short venture
#

so

if (Selection.activeContext == [SomeConstant]) { }

?

hardy apex
#

Yes. I don't know how to figure out what should go in [SomeConstant] because I'm confused on what the type for activeContext is

#

or rather, I know it's type object but I don't know how I define a constant for it correctly

short venture
#

object?
show your Selection class code

hardy apex
#
        if(GUI.changed || Selection.activeContext == [SomeConstant]){
            EditorUtility.SetDirty(target);
            myScript.GenerateWallFromSpline();
        }
#

selection is a built in unity class

short venture
hardy apex
#

My solution deviated pretty far from the above discussion but figured I'd post incase anyone is searching through the logs later
ToolManager.activeContextType was what I was looking for, rather than the object type
ToolManager.activeContextType == typeof(SplineToolContext)) works perfectly

hushed owl
#

Other than some other observer, is there any quick way (with the window class) that would update data on window close?

waxen sandal
#

OnDestroy?

hushed owl
#

Does .Close() destroy the window?

#

That works prefect, thanks!

Description
Close the editor window.

This will destroy the editor window.```
#

Sometimes I over think it 😄

hushed owl
#

Is there any way to fire when a user opens a dropdown?

waxen sandal
#

To fire what

hushed owl
#

A function.

waxen sandal
#

Any popup at all?

#

On open or when an item is selected?

karmic ginkgo
slate cliff
#

Is there a way to get the GUID or path to the csharp file that is running the function?

#

e.g. something like AssetDatabase.GetGUIDForCallingFunction()

peak bloom
#

wait, just noticed what you posted... normally the control over which calling which is in your hand already, so not quite sure you really want

gloomy chasm
# slate cliff Is there a way to get the GUID or path to the csharp file that is running the fu...

No, but you can make one. It depends on exactly what you want.

MonoScript scriptAsset = MonoScript.FromScriptableObject(this);
string path = AssetDatabase.GetAssetPath(scriptAsset);
return AssetDatabase.GuidFromAssetPath(path);

If you want it to work with other classes, then you could maybe do something like.
You should be able to do something like

public string GetGUID()
{
  return AssetDatabase.GuidFromAssetPath(Getpath());
}

private string GetPath([CallerFilePath] string sourceFilePath = "")
{
  // I can't remember exactly what to do here. But basically sourefFilePath will be the file path in relation to the computer c:/something.
  // But you want it in relation to the assets folder.
  string assetPath = sourceFilePath.Remove(Application.dataPath);

  return assetPath;
}
#

Oh, you want it from the one calling it, well same idea, just use [CallerFilePath] to get the path to the file, then you can do the same thing to get the guide.

slate cliff
waxen sandal
#

I don't think so

gloomy chasm
slate cliff
#

Isn't it creating another instance of the script?

#

Ah, it just gets the script, nevermind.

gloomy chasm
slate cliff
#

Thanks!

gloomy chasm
#

Though I think using CallerFilePath would work better for you tbh. It is definitely more flexible.

slate cliff
#

I think I'll have to regardless, since while it is a ScriptableObject I don't have an instance when I need the path

gloomy chasm
slate cliff
#

Seems like kind of a hacky workaround 🤷

short venture
slate cliff
#

How would that work, I don't have a path

short venture
#

yes you do, all resources are in a Resources folder

slate cliff
#

But it's not in the resources folder 😅

short venture
#

why not

slate cliff
#

Because it's an editor asset

short venture
#

can still be in a Resources folder

slate cliff
#

I'd rather not create a resource folder just for this. Also makes porting more complicated

#

I always forget resources are even a thing anymore, since I've used addressables for so long now

gloomy chasm
#

Yeah, the Resources folder should generally be avoided when possible

short venture
#

either you work within the Unity ecostructure or you work outside of it, your choice. But if you are going to work outside of it then dont expect Unity to provide support for what you want to do

slate cliff
#

That could be said of any API that unity has added since their inception, it's just a case of how long it takes and how many people need it

slate cliff
#

Addressables replace the need for resources, and are a more comprehensive system

slate cliff
#

How is that nonsense

short venture
slate cliff
#

You can do both with addressables

gloomy chasm
# short venture Why? Explain

Firstly, it forces anything in that folder to constantly be loaded. This may be fine for one asset, but it can add up.
For editor tooling, depending on the context for the use, it can force the user in to using specific folder structure/organization, having to dive in to 'your' folders to edit something.

slate cliff
#

^ that's why I don't like them for editor tooling

#

I don't think I've ever used the resources folder

gloomy chasm
slate cliff
#

What even is an asset that is "external" to your project?

gloomy chasm
#

@slate cliff What are you doing btw? Is it getting/saving settings for you tool?

short venture
#

omg do you even have any idea what Addressables are?

slate cliff
#

I settled with just using the unity search functionality to find the script file and caching that. I'll leave it at that for now even if it's not the best solution

gloomy chasm
slate cliff
gloomy chasm
sharp quest
#

is there a way to add a context menu item when right-clicking any asset? from my research, it seems like it's restricted to custom monobehaviours

gloomy chasm
sharp quest
#

yeah

gloomy chasm
#

Just use [MenuItem]

sharp quest
#

oh huh, from the examples i saw, i thought that was restricted to methods that were on monobehaviours

#

thanks!

gloomy chasm
sharp quest
#

thats awesome, thank you!

slate cliff
#

Now I've written another small editor extension that I will then forget to ever use ok_handbutflipped

gloomy chasm
sleek basin
#

Hey all, running into an issue where my EditorWindow class is throwing NullReferenceException error

#

`private void OnGUI()
{
if(GUILayout.Button("Click me ")) {
Debug.Log("the button is clicked");

    MyScript.Instance.debugLogs();

    }
}`
#

I am referencing MyScript class by doing:
public static MyScript Instance;

#

Instance = this;

#

Any suggestions on how to fix this?

lone halo
waxen sandal
#

extension has to be .cube iirc

lone halo
#

Ahaaa! Why didn't they just wrote a small comment mentioning that? :P

#

Thanks

waxen sandal
#

Well if you look at the docs for the attribute then it does it is the extension 😛

glad cliff
#

Hey im really new to editor scripting, and im trying to make my first simple tool (I need it for my own project). So far I was able to resolve any problem on the way, but with this one I cant seem to find anything in docs or forums

#
void DeleteParam(int index)
    {
        Undo.IncrementCurrentGroup();
        Undo.SetCurrentGroupName("delete parameter");
        var groupIndex = Undo.GetCurrentGroup();
        var spar = new SerializedObject(serParams[index].objectReferenceValue);
        Undo.RecordObject(so.targetObject, "");
        ((Parameter) spar.targetObject).parent.parameters.Remove((Parameter) spar.targetObject);
        Undo.DestroyObjectImmediate(spar.targetObject);
        AssetDatabase.SaveAssets();
        so.Update();
        Undo.RecordObject((Object)this, "");
        var parameters = so.FindProperty("parameters");
        serParams = new List<SerializedProperty>();
        for (int i = 0; i < parameters.arraySize; i++)
        {
            serParams.Add(parameters.GetArrayElementAtIndex(i));
        }
        Undo.CollapseUndoOperations(groupIndex);
    }
#

im trying to record an undo group here

#

and for long time i thought that for some reason everything records correctly, except the DestroyObjectImmediate, wich deletes one nested scriptible object

#

apperently it records and works just fine, but...

#

when I do CTRL+Z everything goes back to normal, yet the deleted asset doesnt appear for fiew minutes

#

yeah after fiew minutes it suddenly appears in project inspector, but I really dont know what is happening throughout those fiew minutes, I even tried to refresh asset database on Undo/Redo event, but it doesnt help

hardy apex
#

basic question. How can I make my editor script only update when something in the scene or inspector has actually changed, instead of constantly (OnInspectorGUI)

waxen sandal
#

OnSceneGUI?

#

Onhierarchychanged

#

Ontransformchanged

hardy apex
#

For some reason, OnSceneGUI still updates every frame even if I'm not touching anything

gloomy chasm
waxen sandal
#

Only works if you properly use deltatime everywhere though

peak bloom
#

How would you go about baking the transform of a gameObject ?

#

This is my use case, say I've copies of one gameObject then each of the copy would have their own scale... man this is hard to explain in english haha

#

it's similar like when you're applying the Transform in Blender... so the transform will be normalized to 1

#

hope that's not confusing

#

Quite old, but I can work my way based on that

glad cliff
#

I have a problem with my custom editor wich I cant resolve by my own
I try to make a SerializedObject with

new SerializedObject(conditions[j].objectReferenceValue)

where conditions is a List of Serialized properties, and for some reason this objectReferenceValue returns null.
This is simplified object inspected

public class SMTransition : ScriptableObject
{
    [SerializeField] public List<SMCondition> conditions = new List<SMCondition>();
}
[Serializable]
public class SMCondition
{
}

Ofc List of serialized properties in my editor script is manually populated by iterating through this list property, so I am sure that value it stores must be object reference.
So far only clue I have is that I read somewhere that objectReferenceValue may refer only to objects deriving from basic Unity Object, but if its so I have no idea how to bypass it

gloomy chasm
glad cliff
#

ehhh so its true...
SMCondition is a wrapper class to store multiple things in one place, is there any way to achive this inheritance for this class?

gloomy chasm
glad cliff
#

what do I mean with which part?

gloomy chasm
glad cliff
#

ohhhhh w8... what this method is actually doing? it takes the property deeper from hierarchy?

gloomy chasm
#

Yeah, it finds a property relative to the property it is called on

glad cliff
#

i mean, will it return some property from SMCondition?

gloomy chasm
#

Yeah

glad cliff
#

when i read docs i must have misunderstood word "relative"

#

that solves everything I guess wow

gloomy chasm
#

The reason it is relative is because you can give it a path

#

property.FindRelativeProperty("myVectorField.x")
Will return the property for the x field in a vector3 (assuming myVectorFIeld is a vector3 field)

glad cliff
#

Damn... I just realised that one of my editor scripts beeing like 300 lines of code or so, could be actually half as large XD

gloomy chasm
#

Well, that isn't the reason it is called "Relative"

glad cliff
#

One more question if I may.
if SMTransition is my serialized object beeing inspected, will ApplyModifiedProperties() affect this SMCondition fields inside?

glad cliff
#

well unfortunately not... when I change property of SMCondtition inside SMTransition editor window, serializedObject of SMTransition doesnt return true with ApplyModifiedProperies :/
but nvm, thats a minor issue

gloomy chasm
glad cliff
#

is it becouse of

intValue = EditorGUILayout.IntField(serCon.FindPropertyRelative("intValue").intValue);
//and then tryingto apply this value

insted of

intValue = EditorGUILayout.PropertyField(serCon.FindPropertyRelative("intValue"));
gloomy chasm
glad cliff
#

well actually it looks like this in my code

intValue = EditorGUILayout.IntField(serCon.FindPropertyRelative("intValue").intValue);
serCon.FindPropertyRelative("intValue").intValue = intValue;

(I know its a mess without caching it but only for now)
So pretty much the same, but im doing it only becouse this applyModifiedProperties doesnt recognise change in this EditorGUILayout.IntField as a property change

gloomy chasm
#

Try that

glad cliff
#

ahh nvm it works just fine with

intValue = EditorGUILayout.PropertyField(serCon.FindPropertyRelative("intValue"));

thanks rubber duck XD
as I said, minor issue

marble orbit
#

im trying to make a property drawer for a struct and im wondering what it is I need to be able to make a fields for a list

marble orbit
#

okay got it

#

still having some weird issues though

#

atm im struggling with the property drawer height

#

For some reason the property drawer height is being rather laggy in being set, i think im updating the hieight in the wrong section

#

and also if I have a list of them, then only the last one in the list will be updating its value

gloomy chasm
marble orbit
#

I have

marble orbit
#

the problem is that it updates very slowly

#

also that bug where if the property is in a list, then only the bottom element in the list will be updating it

marble orbit
#

just trying to figure out why is behaving so strangely

#

and I need to get it working asap

waxen sandal
#

Shoooow coooooode

marble orbit
#

yea I know that would help a lot 😅

#

but its all behind NDA

#

it gets tricky asking for help when the problems are behind an NDA

clever anchor
#

Hello, I have a script that inherits from Editor for a scriptable object. I have a button already in it and I want to populate a List that's inside the scripable object. Only problem is that I don;t know how to reference the list variable that's in the SO from my editor window

glad cliff
#

Its me again my lovely fellows!

void DrawTransition(Rect rect, int index, bool isActive, bool isFocused)
    {
        {...}
        using (new GUILayout.AreaScope(new Rect(rect.x, rect.y, rect.width, rect.high), 
                   new GUIContent("Condtiions"), EditorStyles.helpBox))
        {
        }
  }

Inside a ReorderableList item im trying to draw an area scope, but it is not beeing drawn where this item list actually is. Seems like rect.y gives me the very top of an inspector window instead of position relative to this item in a list. For now i have written some absolute values and it works for my screen, but I want to keep it relative to actual list position.

#

or maybe this rect passed to this methos isnt actually a rect of an item to draw? I feel like im missing something VERY obvious and trivial

gloomy chasm
glad cliff
#

I figured it out, yet I couldnt find any possible way to surround part of this list item with helpBox style

rancid violet
#
    [GameEffect(ID = "spearEffect")]
    public class SpearEffect : AbilityEffect
    { //Logic in here }

Does anyone know what I could use to replace my current effect system of typing a string in that corresponds to an attribute? I want to be able to have separate values set in the inspector for different items, but want the logic to remain the same in some cases. I am not using SOs right now since I would rather not have to create a separate file and instead keep it all within the ItemData SO.

Is this maybe what PropertyDrawers are for? If so, I see in the documentation they manually add fields for all the SerializedProperties, but would it be possible instead to loop through them so new effects work without modification?

severe lance
#

PropertyDrawers are nice if you just want one large script with most of your data on it. Instead of creating a large hierarchy, you can just create a bunch of structs which you can hide or show on the editor if that's what you want to do.

#

Unfortunately, it's a pain to edit every time you want to add more to your scripts, since you're not only editing the data script but the PropertyDrawer too.

waxen sandal
#

You can quite easily just loop through all properties in a serializedproperty and draw them excluding ones you want to have custom behaviour for

#

Or you can just use a propertyattribute on the field you want to draw different

#

Also, you might be looking for custom editors if you want to change the whole ScriptableObject representation

unique violet
#

is there a way to keep a list in memory even when the editor reload?
ex: I have a [InitializeOnLoad] class where I build a list but any time a c# file is modified, that list is cleared.

waxen sandal
#

You gotta serialize it somewhere

clear kite
#

EditorPrefs is usually used to save custom editor data to disk (you can first serialize the data to string and then save using EditorPrefs.SetString)

waxen sandal
#

Not for complicated data really

#

And editorprefs is shared between projects

#

So you can't use the same extensions in between projects

hollow sigil
#

how to fix this?

rancid violet
#

I can dodge all the file shenanigans and have it do it for me

simple cove
#

that's awesome

twin blade
#

that looks fire

pure siren
#

Why does unity's inspector not support unsigned integer types? It seems silly to have to apply a Range attribute to every field that is unsigned or to have to check it in OnValidate

#

Actually they do work, ulong doesn't seem to work though. I can still assign negative values and can't go above max long value. I wonder if this is a bug and if so, if it's fixed in newer Unity versions. The use case for ulong is probably **extremely **low, so probably a non-issue, just something I noticed.

small pewter
#

i feel like this should exist.. anyone familiar with an editor extension or tool to view scriptable objects of the same type in spreadsheet format?

#

i have an CSV importer / exporter but for values like game object references it's a pain to reconnect on csv import

gloomy chasm
#

Like ```
ScriptableObject Instacne | Field 1 | field 2 | field 3
ScriptableObject Instacne other | Field 1 | field 2 | field 3

small pewter
#

exactly

#

i'm currently exporting to CSV files to view in excel, but i have more complex data types than just ints bools and strings, so setting them on import is a pain

#

was wondering if anyone has see an in-app editor utility that essentially views scriptable objects in a spreadsheet

gloomy chasm
#

I don't know of any my self (might find something on the asset store). But it wouldn't be that hard to make tbh

#

You would use that combined with SerializedObject/SerializedProperty

hollow sigil
#

how do i fix a 2D Box Collider that overlaps another?

celest nexus
#

how to make a collider that fits a 3d object

rancid violet
#

Is there a way to make this editor GUI I've programmed show up whenever there is a SerializeField of type List<GameEffect>, instead of needing to make custom editors for everything that uses them?

waxen sandal
#

You can do so for array/list elements but not for the whole list

rancid violet
waxen sandal
#

Yes

rancid violet
#

Actually that would probably be enough, what do I use to do that?

waxen sandal
#

You got a propertydrawer now?

#

[CustomPropertyDrawer(typeof(YOUR_TYPE))]

rancid violet
#

Ooh okay I'll look into it

fresh briar
#

Is there any way to add a find log to the Console?

#

Search filters out all the other logs. Sometimes it is useful to jump to a certain log and check nearby logs

pseudo jasper
#

When writing a custom editor, is there a way to enter some default search text for an object field? E.g., i'd like to default to filtering assets with a certain label

#

Otherwise it brings up a list of every texture, which is much less helpful!

vapid prism
#

Is there any callback to see when the inspector changes? I want to inject some extra UI to some internal AssetImporters. I was thinking of using Selection.selectionChanged but there might be a better way

gloomy chasm
vapid prism
gloomy chasm
# vapid prism Grabbing the UITK inspector window and adding new elements
public static class EditorGUIUtilities
{
// The TypeTool.GetEvent is just a little utility to get reflected stuff easier. Easy to replace with default C# calls.
private static readonly EventInfo _editorTrackerRebuiltInfo = TypeTool.GetEvent<ActiveEditorTracker>("editorTrackerRebuilt");

/// <summary>
        /// Called when a property window rebuilds it's UI.
        /// </summary>
        public static event Action OnEditorTrackerRebuilt
        {
            add { _editorTrackerRebuiltInfo.AddMethod.Invoke(null, new object[] { value }); }
            remove { _editorTrackerRebuiltInfo.RemoveMethod.Invoke(null, new object[] { value }); }
        }
}
#

Then add a callback to the OnEditorTrackerRebuilt that gets all property windows and checks, what their target is (if it is the one you want) and if you have already added your element to them.

subtle axle
#

Is there any way in odininspector to sort a list of interfaces by the base class instead of just by "User Type"

gloomy chasm
subtle axle
#

Thanks

short prawn
#

Does anyone know why there is a forced recompile and editor window refresh when I enter play mode? It's causing the editor tool I'm making to lose everything done within it. Using UITK, never used to happen with imgui

visual stag
short prawn
visual stag
#

Editors are redrawn in IMGUI too, they're just immediately using values that you've (likely) serialized into the window, editor, or objects

waxen sandal
#

Can you show some code?

short prawn
short prawn
waxen sandal
#

Could be that whatever you're serializing is not serializable

#

Or if you create elements on input field change then that could also be a thing

#

Definitely not as easy to completely restore state in UITK vs IMGUI

visual stag
#

It could also be that UITK is doing something stateful with the editor that you're either not working to be aware of, or is actually flawed. UITK can be a pain in the ass sometimes imo

short prawn
short prawn
waxen sandal
#

Well if you hide/show things in callbacks then you still need to restore that state at start

short prawn
waxen sandal
#

Sure, just making sure that it is happening 😛

native geode
#

Iam creating RPG inventory and am at phase of creating items. Scriptable objects by default are ok until you start having lots of items. I have seen odin and seems great, but often i find free tools even better and open source for customization, my question is have you used any odin alternatives? Serialization and attributes

iron mica
#

Hello Guys,

I am kind of new to editor scripting in unity. I am trying to make an editor window to import objects and set some values through it. I tried to make Label, texts and all UI related stuff with bunch of tutorials, but i couldn't find a relevant one for importing assets.

Basically," I want to import the objects and load/save it in specified project folder and access its properties through Editor Window."

Any help is Appreciated. Thanks in Advance.

lone halo
#

How do I send a list of objects to Selection.activeGameObject ?

#

I can send it newSelection[0] but I want all objects in the Array

native geode
#

Selection.activeGameObject = new GameObject[] { newSelection };

#

does this work?

lone halo
#

I just figured it out, should have been Selection.objects, not activeGameObject

#

But I tested and too and it gave the same convert type error

peak bloom
#

isn't that's what it's doing already ?

waxen sandal
#

Not in the header

#

I guess you can write a script to update the title

peak bloom
#

not quite sure, but I believe I've done this before.. something like this perhaps?

new Window { window = win, content = new GUIContent(win.titleContent) }

you must populate the active windows first then do something like above...

gloomy chasm
#

That class has other useful methods so I would take a look at them as well.

supple willow
#

hi. has anyone found a way to discard changes in a scene programmatically?

hushed mirage
#

Have you tried just calling EditorSceneManager.OpenScene on the same scene? I’d check if that reloads a fresh copy

hushed mirage
# supple willow hi. has anyone found a way to discard changes in a scene programmatically?

Reloading the scene seems to have worked in Unity 5.5 so it seems promising: https://answers.unity.com/questions/1298210/how-to-revert-scene-to-the-last-saved-state-in-the.html

#

I’d be surprised if this scene handling behaviour changed in the meanwhile tbh. can’t check atm but would be curious to know if you give it a try.

somber zinc
#

I'm using UIElements.TextField, is there any way to increase the size of the content (the box where you can enter text) in code? Don't really fancy messing with this USS stuff but it seems like I'll have to if I want to use GraphView.

short venture
somber zinc
supple willow
#

would be cool if they let us just use that discard methd

#

I tried it with reflection, but doesn't work. seems it needs to be called from a specific context

hushed mirage
#

You can request it via the Unity feature request tool or maybe get an alternative solution from a dev on the forums

#

Re: selections, can’t you clear them by nulling it out in Selection object? Re hidden objects, are you saying that hidden objects persist past scene reload?

upper comet
#

Hello. How do I override the inspector for System.Collections.Generic.List<T: Serializable> ? I have a custom inspector for T which works using [CustomEditor(typeof(Mod))], but it isn't displayed when the type is nested in a List<T>

#

Custom inspector (first screenshot), List<T> (second screenshot)

#

I've tried overriding CreateInspectorGUI and OnInspectorGUI but none of them work unfortunately.

#

I'm guessing I need a custom editor for the class that wraps the List<T> ?

#

Indeed, this works - disregard my request 🙂 Thanks

supple willow
#

like, there are multiple iterations of OnGUI etc

#

and different phases of executions (OnEnables, Editor Updates, Delayed calls etc.)

#

so when I call the discardChanges from my code (which uses EditorApplication.delayCall btw) , the array of changed scenes is empty, even though the scene is clearly modified

upper comet
#

Hi! I'm writing a custom PropertyDrawer for class Mod that's nested in another class ModsPool that contains a few fields:

public class ModsPool : ScriptableObject
{
    public ItemType ValidItemType;
    public List<Mod> Prefixes;
    public List<Mod> Suffixes;
}

It works fine, except when I add an eighth element, and at this point it seems like I hit a maximum height or something, see the associated screenshot.
Any idea where it might come from? Disclaimer: I'm a bit lost with editor code so... Bear with me 😄
Here is the full code: https://gist.github.com/tbarusseau/5b1dc17da77cac0c4a4fa8e116b07d22

outer kraken
#

Hey, small question.

Is Physics.Raycast(...) not usable inside a PreviewScene?

ANSWER:
Seemingly, yes it's not, PhysicsScene is what I need to use to make it work, the usual Physics.Raycast was being executed on the MainStage and not my custom one.

https://forum.unity.com/threads/raycast-in-the-prefab-scene.647548/
_

short thorn
#

Hey,

I'm developing a UPM package for internal use.
Is there a way to include certain tags/layers/sorting layers in the package, or do I have to write an editor script to create them?

waxen sandal
#

No default way

twin blade
#

how do i keep the Sprite field IN the screen

#

the whole thing

#

i tried flexible space after it and ExpandWidth true

#

neither did anything

#

i dont wanna hard set a width

thick needle
#

i dont know if it is a bug but TextMeshPro's right click menu creation is not using ObjectFactory, instead it just Add component via gameobject.AddComponent instead of ObjectFactory.AddComponent

#

cause im relying on ObjectFactory.componentWasAdded to do component replacing, the way TMP creates its default text/button/label doesnt allow me to do component swap via script

thin fossil
#

Is there any way to add custom settings to the model import settings inspector?

gloomy chasm
gloomy chasm
thin fossil
#

But injecting UI elements sound cumbersome anyways 😬

#

Would be nice to just have custom settings for custom asset postprocessors

gloomy chasm
gloomy chasm
misty igloo
#

on the problem of how to use EditorGUILayout to draw a serialized reference

patent quarry
#

How do I clamp the value in inspector?
script.radius = EditorGUILayout.FloatField("Radius", script.radius);

gloomy chasm
#

But it would be good to look in to SerializedObject and SerializedProperty as that is the much better and recommended way to modify values in the editor.
They ensure changes will be saved, support undo/redo, and support prefab overrides.

patent quarry
gloomy chasm
pearl geyser
#

Hello I have editor window which uses importpackages inside but problem happens when unity starts doing this then any other import package will be canceled because editor reloaded window

#

Its any fix for that?

#

like if its possible to cancel auto import or stop editor importing anything while in this process

agile badger
#

Is it possible to draw a single mesh inside of a custom editor window? I'd like to write a custom collision editor tool for a UGC game to replace the current (extremely cumbersome to use) system that involves futzing around with the scene view camera and a massive ton of generated collision handles

worldly ginkgo
#

is there any API call to get absolute mouse button state in editor? Or do I really need to keep track myself using the GUI events (as I suspect)?

vital mountain
#

How can i make a list of dropdown menus?
what i want to use it for is to be able to have a scriptable object with a list i can make bigger and the content is dropdown menus that has options from a list of strings

#

so i can make sure that i only select existing things and dont miss spell the name

#

i found this on how to make a list but it doesnt seem to quite work with swapping it out with a list of stringshttps://answers.unity.com/questions/1214828/editorguilayout-list-field.html

#

i got the list to work, then i might figure out the rest

short tiger
#

For more complex rendering, it's recommended (and sometimes required) to use a CommandBuffer

#

Once you have the rendered texture, you can draw it in the editor window as you would any other texture

agile badger
#

Alrighty! Let's restitch this thing then!

#

(that pun might've broken my NDA)

vital mountain
#

so ive got it working, though is there a way to make it look a bit more like a list? right now im pretty much just using loops to draw the popout fields. is that maybe what the rect fields are for? making things look pretty?

agile badger
short tiger
agile badger
#

Ah. I want to use an orthographic "camera" because this is a 2.5D game and I don't need to view the mesh in 3D

#

Also I read that Graphics.DrawMesh doesn't render immediately when you call it...

short tiger
#

Okay, for that you use Matrix4x4.Ortho method to create the orthographic projection matrix

#

Oh yeah, you could be using Graphics.DrawMeshNow

agile badger
#

Not exactly. It doesn't look like there's an overload for passing materials and submesh indices

short tiger
#

You can material.SetPass to set the current material, which subsequent draw calls will use

#

And it looks like the "materialIndex" actually means submesh, since it's described as: "Subset of the mesh to draw."

#

Alternatively, you can use CommandBuffer, which has a more straight-forward DrawMesh function

#

The difference is, you create a CommandBuffer object, add all the commands into it by calling its functions and then call Graphics.ExecuteCommandBuffer.

agile badger
#

man I'm getting flashbacks to when I tried to write my own engine

short tiger
#

Here's a full pseudo-code example:

var renderTexture = new RenderTexture(...);

var cmd = new CommandBuffer();
cmd.SetRenderTarget(renderTexture);

// Setup the "camera"
var camViewMatrix = Matrix4x4.TRS(cameraPosition, cameraRotation, Vector3.one).inverse;
var camProjectionMatrix = Matrix4x4.Ortho(-5, 5, -5, 5, 0, 100);

// The projection matrix needs to be converted for the GPU
camProjectionMatrix = Graphics.GetGPUProjectionMatrix(camProjectionMatrix, true);

cmd.SetViewProjectionMatrices(camViewMatrix, camProjectionMatrix);

// Now we can finally draw the mesh
cmd.DrawMesh(mesh, Matrix4x4.TRS(meshPosition, meshRotation, meshScale), material, submeshIndex);

// And execute.
Graphics.ExecuteCommandBuffer(cmd);
#

For performance, the render texture and command buffer should be pooled. There's a built-in pool for RenderTextures through either RenderTexture.GetTemporary/ReleaseTemporary or CommandBuffer.GetTemporaryRT/ReleaseTemporaryRT. The CommandBuffer you can just cache and reuse, using Clear() to reset it.

agile badger
#

Right! I HAVE a donut prop rendering!

#

But it's solid gray

#

The mesh SHOULD be red and white though

#

@short tiger Any reason why it would be solid gray? It's like the material isn't actually being used

#

Could I have potentially missed something?

private void RebuildCommandBuffer()
{
    if (previewCommandBuffer == null)
    {
        previewCommandBuffer = new CommandBuffer();
    }

    previewCommandBuffer.Clear();
    previewCommandBuffer.SetRenderTarget(meshRenderTexture);
    previewCommandBuffer.ClearRenderTarget(true, true, previewBackgroundColor);

    float aspect = (float) meshRenderTexture.width / (float) meshRenderTexture.height;
    float halfHeight = 5;
    float halfWidth = halfHeight * aspect;
    
    Matrix4x4 view = Matrix4x4.TRS(camPosition, Quaternion.Euler(camEulerAngles), camScale).inverse;
    Matrix4x4 camProj = Matrix4x4.Ortho(-halfWidth, halfWidth, -halfHeight, halfHeight, 0, 100);

    camProj = GL.GetGPUProjectionMatrix(camProj, true);

    previewCommandBuffer.SetViewProjectionMatrices(view, camProj);

    Matrix4x4 matrix = Matrix4x4.TRS(meshPosition, Quaternion.Euler(eulerAngles), scale);
    for (var i = 0; i < propMesh.subMeshCount; i++)
    {
        previewCommandBuffer.DrawMesh(propMesh, matrix, propMaterials[i], i);
    }
}
short tiger
agile badger
#

How do I solve that without switching to an unlit shader for all of the materials?

short tiger
#

You can set them with CommandBuffer.SetGlobal{Vector/Float}

short tiger
#

Then _LightColor0 and _WorldSpaceLightPos0 should be all you need to set, with color and direction respectively.

#

maybe also need to enable the DIRECTIONAL shader keyword with CommandBuffer.EnableShaderKeyword, if your shaders expect that keyword.

agile badger
#

What do I set the direction to? I'm too dumb to comprehend Vector4 for anything other than colors lol

short tiger
#

If you set it to (0, -1, 0, 0), the light will be directly above, pointing down (negative Y). The w component is expected to be 0 when it's a direction instead of a position, but I'm not sure it actually matters.

#

So it's just a (world space Vector3 direction, 0)

agile badger
#

The mesh is still solid gray

#

I may just need to take a screenshot of the editor and break my NDA, I'm really confused

short tiger
#

No worries, I'm imagining a solid gray mesh in my mind's eye

#

Does it look normal if you use an unlit shader?

agile badger
#

I'm afraid to change the material to find out. I don't want to wipe out any properties that are set on it currently since I'm not an artist.

#

But I guess I can always git reset

short tiger
#

Is it easier to swap the material instead of the shader?

agile badger
#

Neither is actually possible

#

The material itself is read-only, and the mesh filter I'm reading from is imported from an asset

short tiger
#

Can I ask if the shader is the Standard shader or something custom?

agile badger
#

Yes, it is the Standard shader

short tiger
#

Alright, I'm setting up a quick test project to see if I run into the same problem

agile badger
#

I'll take a screenshot of what I'm actually seeing just to be sure

#

The cyan background is intended, to depict a "sky"

#

It's like it's the same shade of gray as the background of the editor window, which is weird.

short tiger
#

Oh that might mean the shader is writing 0 to alpha and the texture is drawn as transparent

#

If you're using GUI.DrawTexture, there is a alphaBlend parameter that should be set to false

#

Btw, it looks like you have to specify the shaderPass in DrawMesh, otherwise it will try to draw all passes, which causes weird issues. Pass 0 in the Standard shader is the base pass

agile badger
#

Setting alphaBlend made the mesh look black

#

Setting shaderPass to 0 makes it invisible

short tiger
#

Yeah, I'm still struggling to get lighting to work

#

In general, it's recommend to use Graphics.DrawMesh to fully support lighting, but that requires a scene

#

There's definitely some combination of properties and keywords that will get lighting to work, but it might not be worth it.

#

You might want to look into editor preview scenes, to manage a scene from editor code and render from that

#

But I'm going to keep trying anyway because I want to figure it out. I'll let you know if I do.

agile badger
#

I honestly just want to see the mesh in color, without lighting

#

I don't need lighting for the collision editor tool

#

I just need to see where the mesh is

#

And draw collision representations over top of it that an artist can drag to move and resize

short tiger
#

Yeah, but Standard can't render as unlit, it always needs some lighting. I'm trying to get basic, uniform ambient lighting working.

agile badger
#

Agggh shaders

short tiger
#

I mean, if you know that all these meshes are going to be using the Standard shader, you don't have to use their actual materials

#

You can just substitute it with your own simpler unlit shader

#

Get the main texture from the imported material and set it on your unlit material

agile badger
#

I wonder if using editor preview scenes would be better, I mean it would be nice to use Unity's default collider editor UIs instead of trying to develop my own. Especially for polygon colliders which will be needed for more complex meshes

short tiger
#

I don't think a preview scene will make drawing editor handles any easier. It's still like a regular scene, not like the scene view.

agile badger
#

The only problem with using the default Scene View for this tool is the camera. Forcing it to a certain position so you don't have to futz with it manually, things like that. And then the Inspector starts to become limiting too because I effectively have to write an entire state machine into a custom inspector just to get this all working the way I want it to, and manage colliders on a temporary object in the scene, just a massive mess

short tiger
#

But there is the stage API, which is what the prefab editor uses. That might be closer to what you want.

agile badger
#

Only if it can be used inside of a custom window.

short tiger
#

Then no

#

I don't know how difficult it is to draw editor handles in editor windows. Never tried that, only used them in the SceneView.

agile badger
#

What'd you do?

short tiger
#

There's a lot of code just for converting the SphericalHarmonicsL2 type (which is how light probes are encoded in Unity) to the shader properties, which I've stolen borrowed from Keijiro

#

Complicated math I don't understand

#

But the actual probe creation is as simple as can be:

var probe = new SphericalHarmonicsL2();
probe.AddAmbientLight(ambientColor);
probe.AddDirectionalLight(lightDirection.normalized, lightColor, 1);
visual stag
#

You could also just use PreviewRenderUtility

short tiger
gloomy chasm
#

Yeah it is very undocumented but you can find some good resources online for it. And it is very flexible as it basically gives you full access to the preview scene and everything, that is unless you want transparent backgrounds, then you are out of luck.

agile badger
#

This method appears not to exist @short tiger

previewCommandBuffer.SetKeyword(material, new LocalKeyword(material.shader, "LIGHTPROBE_SH"), true);

I'm using 2020.3.4f1

short tiger
agile badger
#

I'm very closely zoomed in... And you can see it's TRYING

#

It's REALLY TRYING

#

I can make out the red and white stripes of the floatie prop

#

You can see the sections if you notice the red pixels and the white ones

#

But as you can see... it's not quite... right

#

Still pretty black. Not sure why.

short tiger
#

I think this is another pass drawing on top, mostly obscuring the first correctly lit pass

agile badger
#

Nah, I am specifying the pass

#

I actually think it's my render texture format

#

Since I created it with new RenderTexture(width, height, 0); where 0 is the depth

short tiger
#

Mm, I think 8 is minimum to get proper depth writing/testing

#

Documentation says this though

(0, 16, 24 and 32 are supported)

misty igloo
#

been wracking my brain and I'm sure someone else has done this, but I want a null entry in the inspector to show a red label and make the label of every parent property up to the parent red as well

#

like so

#

was thinking originally of using an attribute to achieve this which works fine on the level of the property itself but doesn't play ball when going back up the stack

short tiger
misty igloo
#

I was then thinking of going from the root itself but wasn't sure if using a default EditorGUILayout.propertyField would respect child properties custom property drawers

#

it's not the same type

#

it's all under one component

#

but each of the properties are varying classes that form the whole

#

like this

short tiger
#

Assuming this is drawn with EditorGUI/Layout, as opposed to UI Toolkit, the only way to achieve this is to check for the null property in the parent drawers.

#

You can't retroactively change what has already been drawn in immediate GUI

misty igloo
#

was thinking it would have to come from the root editor drawer

short tiger
#

It should be doable, but the SerializedProperty iterator is a bit of a pain to use

misty igloo
#

yeah

#

wasn't looking forward to recursively searching down the stack

#

would have to check if it is currently being drawn etc to save on wasted cycles

#

but still have to go down the stack to find all the null references :/

agile badger
#

OKAY. I GOT IT TO WORK. Note to self. Camera must not be at the same Z coordinate as the object

#

Because then it'll near-clip

short tiger
#

Or make the render texture higher resolution than the drawing rect to super sample it.

agile badger
#

I'm just making the rt match the size of the available space in the window - the width of inspectors

#

Bu the end of this it's gonna feel like an entire external program inside of the Unity Editor lol

agile badger
#

Agggh so turns out @short tiger that, although I CAN get the mesh to draw

#

I can't actually draw collider previews 😛

#

Can't draw circles, capsules or polygons

#

At least...not without a terrifying amount of DIY rendering code

agile badger
#

Aggh so I can use Handles inside a render texture and that works great except for the fact that the matrix is all smashed

long bough
#

Does anybody know if there is a way to get the highlighted string in a TextMeshPro text field in the inspector? I am trying to find an answer it the documentation and have had a look at some TMPScripts that looked promising but I found nothing in this regard.

waxen sandal
#

Ugh, I forgot what it's called

#

Effectively the sample there but it's quite undocumented

long bough
#

Thank you, I will give that a thorough look!

#

I came across this and it looked promising, but maybe it's because my lack of practice in working with Editor things that I couldn't get it to work: https://answers.unity.com/questions/275973/find-cursor-position-in-a-textarea.html

waxen sandal
#

Yeah it's pretty much the same thing that I linked

visual stag
#

I also wonder if things have changed with UIToolkit

waxen sandal
#

IIRC they haven't when I looked a year back or so

#

But they might

#

I was also still on 2019 with shitty uitk 😛

long bough
#

Hrm, UIToolkit might be a lead, too 🤔

#

I haven't looked at that at all

#

Well, it has something for selecting strings in a TextField, but it doesn't look like it offers the other way around 🤔

waxen sandal
#

Could check the source and see if there's some reflection way

visual stag
#

UIElement's TextField has a textSelection object that provides a bunch of detail

#

You should check what you're actually dealing with though! Use the UIElements inspector to see whether it's even UIToolkit

long bough
#

Thank you, will do :) I feel like I'm stepping out of my current skill-level with this idea I had, so maybe I'll just need a bit more time to understand and learn before I can tackle this specific thing MaximusJonesLove

#

Reflections are definitely something I'm not prepared to tackle yet, I'd say 😉

waxen sandal
#

Feel free to ask more questions

#

Reflection isn't that hard 😉

long bough
#

All my friends tell me they are the path to the dark side 😅

visual stag
#

Also to be honest while I haven't been participating in this channel much, us editor people are the best of them 😛

waxen sandal
#

❤️

long bough
#

I'd guess you are very patient for sure :D Not only struglling with writing code for own programs, but also fighting with the code of assets or Unity itself to get stuff to work takes a special kind of dedication 😁

visual stag
#

I'm making my own gizmo rendering and nothing has ever been this painful

waxen sandal
#

Ha, I've tried that before

visual stag
#

I always knew I would port my debugging thing from using a jabillion Debug/Gizmos.DrawLine to something more sensible

#

but I expected the hard part to be the rendering and not just routing gizmo calls correctly

long bough
#

Hmmmm you might have given me an idea though. Let's see how this rabbit hole will turn out.

visual stag
#

I would advise downloading and using the Unity C# source (pinned to this channel), if you ever think you're close to something or want to check if something does what you expect it might, it's always a great resource

#

If a quick google fails me usually I will just search the source for some of the terms

long bough
#

wow, that's quite a resource. Thank you for pointing that out, it's been a while since I have used the pinned messages anywhere MaximusJonesLove

agile badger
#

Anyone know a way to build a custom selectable list of items inside an Editor Window? Something like the Scene Hierarchy but as a list instead of a tree.

waxen sandal
#

TreeView?

agile badger
#

I need to do this with GUILayout/EditorGUILayout ideally

waxen sandal
#

Nope

agile badger
#

Is there then a way to get the remaining space while in a GUILayout.BeginArea()/GUILayout.EndArea() block?

teal tinsel
#

What is lifecycle of PropertyDrawer? What can I cache on the instance and what I should not?
If I have multiple property of same type, will same PropertyDrawer be reused for them?

waxen sandal
#

Generally yes

#

You can disable caching but it's been iffy when I tried it before but that might be on me

waxen sandal
#

What header?

#

Why not just draw a button with a position, why do guilayout?

#

GUI.Button?

#

Again what header?

#

If you insist on guilayout then use a horizontallayoutgroup or use positions for both

#

Or use an expander

#

Eeeexpaaaaandeeeeer

lost lark
#

is this used

#

unity visual editor?

outer panther
#

not sure if this is the right channel to ask about this but, how would i hide variables when the bool is false? ive looked online and ive not found anything talking about doing it in scriptable objects

waxen sandal
#

Use a custom editor

outer panther
#

just had a try with that and im getting the error "'Object' does not contain a definition for 'HasChoice'" and for the other variables

waxen sandal
#

Use serializedproperties instead

rough fractal
#

hey there, does anyone have experience with scene dependencies?
When running my scene on mobile instead of desktop I delete a number of assets as well as prefabs from serialized fields in my managers. Yet, even when the scene is basically empty, when I use Select Dependencies it still shows all the assets that were previously linked in the manager. How can I get rid of these conections?

#

EDIT: It seems the reason is that some of my objects are connected to prefabs, when I unpack the objects with the now empty connections, the dependencies are gone

short prawn
#

Am I not disposing of something properly here, or is Unity just being arsey again?

visual stag
short prawn
visual stag
#

Ah, it's the gameobject inspector. Then I'd imagine it's not your fault

short prawn
midnight cedar
#

is there a way to add/remove a define constrain for an assembly definition file with editor script? I can't find a way, do I have to regenerate the whole file?

stray badge
#

Is it possible to get old projects using these files

candid bolt
#

So I'm working on a custom editor tool for modifying my own terrains via tiles/grids and I'm trying to overwrite the Unity events that interface with the scene view when I'm painting or using my tool. I'm currently doing Event.Use on EventType.MouseDrag EventType.MouseDown and EventType.MouseMove and it's working to stop the actual object selection and scene camera rotation but I can still see this box selection behavior. Any ideas how to correctly set this up?

gloomy chasm
gloomy chasm
candid bolt
glad pivot
#

what is it that decides the window name for EditorWindows?

waxen sandal
#

EditorWindow.Title

glad pivot
#

ah, thanks

#

that seems to be deprecated, but i tried this and its still called "MyWindow"

[MenuItem("Multi Scene Workflow/Scene Manager")]
static void Init()
{
    // Get existing open window or if none, make a new one:
    SceneManager window = (SceneManager)EditorWindow.GetWindow(typeof(SceneManager));
    window.titleContent = new GUIContent("Scene Manager", "Loads, Unloads, and Saves Scene Collections");
    window.Show();
}
waxen sandal
#

What's your class called?

glad pivot
#

wait hold on ive accidentally made two classes the same name so its creating an error

waxen sandal
#

Yeah I feel like there's something else going on

#

either in your code or the layout engine is messed up and you should reset it

glad pivot
#

there we go. it was the class name conflict so it didnt update shruggie

glad pivot
#

what do i use to save settings for the editor?

#

i want to save an array of paths so its easier available and i dont need to keep it in a scriptable object or something

#

as this is only for loading scenes with a window

signal temple
#

Is any body know how to create editor window aside from another one ,like this ?

waxen sandal
short venture
short thorn
glad pivot
signal temple
# short venture Please explain

I am creating a custom window editor in unity, and I can't get multiple taps to load side by side when i click on the menu item

#
[MenuItem ("GameObject/My Editor")]
public static void ShowWindow() {
    var w = GetWindow<MainWindow>();
    var tap = GetWindow<MainSidebar>("sidebar", typeof(MainWindow));
}

this is what i do

#

this is what i see

#

this is what i want

short venture
#

this typeof(MainWindow) is desiredDockNextTo so you are getting what you asked for

waxen sandal
#

There's a few way to save data in editor with different use cases:
EditorPrefs, good for 1 or 2 values that are fine to be shared between projects
ScriptableSingleton, the best way for more complex serializable data
UITK ViewData/Serialized Fields on the editor window, good for temporary data in editor windows that needs to survive domain reload (does not persist if you completely close the window)
SessionState, as the name says, persists during the whole session of Unity and is deleted on close

signal temple
short venture
#

I know what you want, but that is not what you have programmed

signal temple
#

yes,but i don't know how to create window that i want...

short venture
#

it's simple.

  1. dont pass a desiredDockNextTo parameter
  2. get the Rect from MainWindow
  3. use that Rect to calculate the position of MainSidebar
signal temple
#

i want these two windows attach together

#

like scene view and inspector

short venture
#

you mean you want a split pane?

signal temple
#

is this works on editor window?

short venture
signal temple
short thorn
#

anyone know what's a safe way to get a unique id for Progress.Report(), apparently it needs to be an int

#

using it in an editor window if that helps

#

nvm, found it, your suposed to call Progress.Start first,t hat returns the id 🙂

candid bolt
#

So I'm working on an editor tool for painting custom meshes and I'd like to use a hotkey to toggle the feature on and off. Problem is it's an Editor Window so I'm using a delegate for OnSceneGUI to check for input. Whenever I toggle the hotkey on it works but gives me this error in the console Getting control 0's position in a group with only 0 controls when doing Repaint

#

I suppose this is because the OnSceneGUI events are happening between the Layout and Repaint stages, but I'm not sure how else to check for input within the editor.

wide plover
#

Hello! im trying to install unisense, however my unity is being stubburn.its a git plugin, and even on the offical unisense github page it says to install it through a link using "install git plugin with url" heres a photo of what my unity tells me! (one moment unity is booting up)

wide plover
visual stag
#

Read the whole error

wide plover
#

yeah, but why does it have trouble?

#

please let me know if im being slow

visual stag
#

What's in the whole error?

wide plover
#

error adding package

visual stag
#

It only says that when you click it in the console window and look at the whole thing?

wide plover
#

oh shit

#

i feel really slow rn

#

but like why do i need git installed on my pc...

#

shouldnt it just install thru unity?

#

i feel really really slow rn

visual stag
#

Unity doesn't have a built in git

wide plover
#

oh

#

sad

#

alr ill brb

candid bolt
#

Could put it in OnGUI but then I could only read the inputs when the active window is the editor window and I want to be able to turn the feature on and off from the scene view.

visual stag
#

You should probably be using a ShortcutAttribute with the context set to the SceneView if you're using your own shortcut. I presume it would then be called at a nicer time

#

And then the shortcut would also be rebindable

candid bolt
#

Yeah that sounds better indeed. Any pointers on how to set that up?

#

I guess one hack would be to make a private bool in the entire class and just toggle it and exit the GUI with OnGUI when it's true and set it back to false

wide plover
#

finally, it works. thank you vertx

lyric flame
#

I don't really know where to ask this question, but if anyone has some experience with Perforce:
Is it possible to automatically checkout files that you want to change?

visual stag
#

I was hoping that ShortcutAttribute would be the former, and involve no work, while getting the benefits of a configurable setup