#↕️┃editor-extensions
1 messages · Page 67 of 1
k now im at like 200 errors
Hi guys, Im having a problem with CustomPropertyDrawer:
I have a abstract class BaseProvider and a class Provider<T> : BaseProvider.
I also have a abstract class BaseElement : MonoBehaviour, it has a public List<BaseProvider> providers.
Then there's a component which derives from BaseElement and has a public Provider<bool> testProvider
I've declared a CustomPropertyDrawer(typeof(BaseProvider), true), it works for the list declared in BaseElement, but the field on the component isn't showing up
anyone know how to go about binding a list/array to a custom VisualElement (and detecting changes to it)?
currently attempt is this hacky thing, but surely this isn't how i'm meant to do it (and it doesn't update when the list changes): cs public class InspectorList : BindableElement { public override void HandleEvent(EventBase evt) { if (evt.eventTypeId == 38 && !string.IsNullOrWhiteSpace(bindingPath)) { var type = evt.GetType(); //for event type 38/setting the serialized object, it's SerializedObjectBindEvent which is internal SerializedObject obj = type.GetProperty("bindObject").GetValue(evt) as SerializedObject; array = obj.FindProperty(bindingPath); UpdateList(); } base.HandleEvent(evt); }
So i've got a bit further (still using that hacky thing to bind, but it seems to work fine). The issue i'm having now is using this code: https://hatebin.com/fqdjkatmhr , when I update the list by clicking the add or remove buttons, the property fields get recreated empty. The UXML is just <InspectorList name="HitList" binding-path="meleeHits" />
here's a video of the behaviour
the log shows that the SerializedProperty is working as expected.. but the new PropertyField(property) seems to be creating an empty property field?
but only when i refresh it sometime after it was bound
Ah nvm I got it.. I needed to do propertyField.Bind(property.serializedObject); after creating it
Does anybody know a way to quickly trigger a domain reload using a script?
I set Domain Reloading to off and it could be helpful when debugging to have a button that I can press that will trigger a domain reload
@austere adder
public static void RecompileUnityEditor()
{
BuildTargetGroup target = Utility.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
string rawSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(target);
// Force Unity Editor to recompile.
// Thanks to darbotron @ http://answers.unity3d.com/questions/416711/force-unity-to-recompile-scripts.html
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, rawSymbols + "a");
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, rawSymbols);
}
For the button
thanks!
looks very useful
[MenuItem("Tweaks/Recompile",priority = 0)]
static void Recompile()
{
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
}
I found in the link from your code snippet a one liner solution. I'm probably going to use NG Hub for more complex tools but right now a simple menu item is enough
This method appeared very lately
Since 2019.3
If you work on recent versions, yeah take whatever suits you
yeah
Hello guys! I have a question. Does is there any kind of check to Editor.target can be equals as root object from hierarchy?
What I want to achieve is : I have 2 objects with the same scripts ( child and parent ), and with editor script there is 2 scripts attached to both of them, + they have a button. I want button to be pressed only from root gameobject ( parent )
transform.root is a thing right?
yes but
Use hastebin to post code
Well target is a monobehaviour so you just get the transform from that
I cant, because its not monobehavior
What's tool then
its Editor.target
Tool this is my custom script
Oh i get
what you mean
stll didn't help
@waxen sandal https://hastebin.com/sigalanito.cs
how i can draw gizmo in Editor script?
You don't, you use handles
https://docs.unity3d.com/ScriptReference/DrawGizmo.html this is also a thing nowadays
Idk if it works for editors
how i can enable/disable it?
how can i play a sound when something = true?
Anybody know if there is documentation on accessing the hide/visibility scene hierarchy through script?
Anyone uses async/await in editor context?
Nope
It was a nice way to manage animation without coroutines. But now there's a package for the Editor Coroutines.
await's great, I wonder if it'd be easy enough to hook into Unity's editor update loop so you could yield back there similar to UniTask
Im just starting but that's only bcoz i need to use AngleSharp, which uses it (at least in the example, so might as well learn it)
Just wondering what are ur use cases? Is it really just a more "proper" coroutine?
I tried EditorCoroutine, and i dont mind coroutine in general except for the fact it can't return unless u do the Action<Image> callback stuff.
Actually, i dont really mind that either.
So basically the other question is, why await/async over coroutine?
(This is getting further from editor specific...)
Hmm should i move this to #💻┃unity-talk i wonder..
Is there a way to change Unity built in preferences by script?
what is a built-in preferences?
I just mean like these
the preferences I didn't add myself
if I know the key, can I just do EditorPrefs.SetInt(key, value);
?
I'll go check the registry to see the key
The classe used is UnityEditor.PreferencesProvider
Which is internal
Almost all the things used is in PreferencesProvider
So yes to answer you, you can do it by script. @lucid hedge 🙂
Okay
Specifically I wanted to change the shader variant limit and it seems they use this key
So I'll do some testing
If it works, it works
Can't you load them as a serializedobject?
how can I conditionally hide an array in the inspector?
Write an editor that does the check
I tried making an attribute for it, but the drawer gets the entries of the array rather than the array itself...
Yep...
so if it is impossible with an attribute, how else do I do it then?
is this a unity limitation or a c# limitation?
??
the fact that attributes apply to entries of the array rather than the array itself
You gotta pick either of the methods, Unity picked for elements
Unity's limitation/design
that sucks
From Unity 4.2 or around
Sucks for you maybe, is great for someone else
sure
that sucks
@austere sun You're not alone, I feel it sucks too 🙂
so basically a 'drawif' attribute it useless since I need to write custom editors for classes that have arrays anyways
and there's no generalization that I can do?
or you would need to wrap the array in a class
Much uglier, and makes the PropertyDrawer works
hmmm
that might actually not be a terrible idea
I constantly hit walls like this when working with unity for some reason
It's sad they didn't provide an option to select between entries and the array
Well now you have a drawer for it
So you can fix it
I wonder if you can inherit from List<T> and do a drawer as well
Since it's not directly a list
Hi, does anyone know whether or not it is possible to disable 3rd party CreateAssetMenu? Ideally I would like to hide it completely.
The most obvious solution is to remove it from code. But the code might be precompiled into a DLL. Second problem with that solution is future updating.
Is there any other way?
@vast needle Not sure it will work, but check UnityEditor.Menu
It literally has a method RemoveMenuItem()
Can someone help? https://pastebin.com/7A7vEDTM
Anybody using UIElements?
I wanted to know, how do you make a ListView expand with it's number of child elements?
@onyx harness I love you man!
Did it work?
@onyx harness I could not test it yet. I just managed to find out its internal. I will give it a go tomorrow with some reflection magic
There is also a question of when to call it.'
@onyx harness It is internal in 2019.4.3f1
How do I get my UI Editor to work for child objects? Eg.
[CustomEditor(typeof(item))]```
Then the Inspector class would apply it to childs of ``item``, rather than just ``item`` itself?
For context, I'm making a dropdown selection for the type of ``item`` it's going to be (the component gets replaced by the child of the base class)
Overloading would be for methods, right?
Add ', true' after 'item)'
Constructors can be overloaded as well
Hmm. This particular class isn't derived from theEditor, but derived fromMonoBehaviour(since it's a component). Perhaps maybe a misunderstanding due to the lacking context. Thanks for trying though.
Add ', true' after 'item)'
Worked perfectly. Thank you.
When you apply an attribute to a class you create an instance of that type
Thus invoking the constructor of that type (In this case CustomEditor)
Thus you need to invoke one of the constructor overloads which enables the custom editor for derived classes as well
Which is what you're doing by applying Mikilo his suggestion
Ooh, ok! I understand now. Thank you
Literally the same as you're doing now
@onyx harness It is internal in 2019.4.3f1
@vast needle Just tested it in 2019.4.0f1, and it worked surprisingly perfectly
@onyx harness but it was internal, right?
Yep, the method yep
Btw thx for testing it
where did you call it? I mean - in some InitializeOnLoad callback?
var m = typeof(Menu).GetMethod("RemoveMenuItem", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
m.Invoke(null, new object[] { "Assets/Create/Shader" });
I tested it throught a MenuItem
I didnt try with InitializeOnLoad, might work differently, since it is the first frame
But you can call a delay from it, should work
Ok, I will give it a go. I hope I can fully automate it.
should not be an issue
You can't paste big chunk of code
All my searches lend me to questions posted in 2011-2012
Has unity ever introduced a feature that allowed you to change the default folder a specific type of asset gets created in?
Specifically creating a script through a gameobject?
Or maybe creating an animator or an animation through the animation window
i am just disappointed because that should be a thing already
I don't anyone really uses it tbh
why should that be a thing.
you can set it up but its workflow and project specific so there rly is no point
You should be able to change it
There's no reason it should be in the root if all your scripts are in some asmdef
Hello friends! I have a question :
https://hastebin.com/noyasureda.cpp
Can I pass "this" into gameObject.GetComponent<???>() ?
Looking for confirmation, (hoping I’m wrong):
Some types can be displayed directly (using and returning an instance of the object), with GUI and EditorGUI functions like IntField, FloatField or BoundsField.
But there is NO built-in method to display these types as an array or List, WITHOUT using a SerializedProperty. Is this correct? ? (I can roll my own, or create a temporary SerializedProperty, which is fine, just wanted to confirm this is necessary before I do so.)
Displaying an array is a bit boring, but completely fine and doable without SP
You can even use UnityEditorInternal.ReorderableList if you are lazy
Even if it's a bit boring, everyone just seems to implement a shitty array
While the Unity array has a bunch of small features that make it easier to work with
Yes, this IS about being lazy! I don't want to do it it I dont have to 🙂
hmm.. Unable to find official docs on ReorderableList 😦
There are none
That's why it's in UnityEditorInternal
IIRC Aras is putting effort into getting it into Unity 2020
hmm,, all the examples I'm finding for it.. DO use a serialized property.. should I keep searching for a variant that doesn't?
Oh yeah ReorderableList is pretty reliant on serialized property iirc
Lol
not at all
It just displays element of a list
Just that
Ok ok, it can rely on SO & SP
But it is just a wrap
test 123
456
789
0-=
hmm, I pasted in some code and my post vanished.. odd
well, think I found a promising constructor line 343 https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/GUI/ReorderableList.cs
Dont post big chunk of code, or you will be temporarily banned
thanks guys! helpful as always ❤️
If you have an ide open yeah 😛
its only a matter of time before you can do that stuff on github I'm pretty sure
they already have it for typescript
I saw it for PHP
Most of the type I just need the definition, not the whole implementation, which make the an IDE ideal, but yeah you need one around
In editor, how to save Texture, but as Sprite?
var bytes = ((DownloadHandlerTexture)www.downloadHandler).texture.EncodeToPNG();
File.WriteAllBytes(path, bytes);
Something goes between there.
Do i save the Texture, do Sprite.Create, then do AddObjectToAsset to the texture?
Nope you just need to set the asset as a Sprite
How do i do that other than selecting all texture then in inspector change to Sprite in the dropdown?
i dunno where else to ask this question but is 2020.1 supposed to have so many loading times?
Do you have more specifics?
it doesn't usually show hold on every time i modify a script
I'm populating a Tilemap, and I'm creating Tiles via ScriptableObject.CreateInstance. I then set the sprite to the tile, and then set the tile in the tilemap
I'm targeting Windows, and of course, this is inside an editor script. Does anyone know what could be wrong?
Tile tile = ScriptableObject.CreateInstance<Tile>();
tile.sprite = sprite;
var position = new Vector3Int(0, 10, 0);
var importedTileTransform = goTilemap.GetTransformMatrix(position);
goTilemap.SetTileFlags(position, TileFlags.None);
goTilemap.SetTile(position, tile);
goTilemap.SetTransformMatrix(position, importedTileTransform);
goTilemap.SetTileFlags(position, TileFlags.LockAll);
goTilemap.RefreshAllTiles();
sprite is not null either
I have VS as my editor in unity I have 2 editors for work one is VS and one is atom in unity I have VS as the editor but it opens Atom rather than VS help m
Okay, regarding my problem above, I added a SpriteRenderer to check if it even displays, and it does
Gah, I'm not seeing the problem here
can I find the default implementation of the OnGUI method for property drawers somewhere?
Why UI?
because it has to do with ui
lol rip
Do you have a particular property drawer in mind?
Cuz I won't show you the code of every PD
there are multiple? 👀
There is a PD for many things yeah
Is that an enum?
no im not talking about the enum specifically
SpecialLayer is of a certain Type, right?
yes
This Type is serializable
yes
SerializedObject (SerO) will wrap it and provides you a SerializedProperty (SP)
From the SP, you can easily draw it
maybe I need to give more context
but it's quite a story
go straight to the point
okay so I'm trying to make an attribute so that certain fields only get drawn when a condition is met (ie. an enum in the class instance has a particular value)
does that work for arrays?
Hum... Can't tell
Don't remember
But i should work for your Type which is a class
not an array
isn't it?
yes but I want it to behave differently when its part of an array
wait let me show a screenshot
using UnityEngine;
[CreateAssetMenu(fileName = "New Test", menuName = "Test/Test")]
public class TestObject : ScriptableObject {
public TestThing testThing;
public TestThing[] testThings;
[System.Serializable]
public class TestThing : IDrawConditioned {
public Foo foo;
[DrawIf("foo", Foo.Sliding)] public Bar bar;
[DrawIf("foo", Foo.Static)] public Sprite sprite;
[DrawIf("foo", Foo.Animated)] public Sprite[] frames;
[DrawIf("foo", Foo.Sliding)] [DrawIf("bar", Bar.Alpha)] public string hi;
[DrawIf("foo", Foo.Sliding)] public float speed;
public bool always;
public enum Foo {
Animated, Sliding, Static
}
public enum Bar {
Alpha, Beta, Gamma
}
}
}
how it looks in the array currently is exactly what I want
but when it is not in an array I want it to be foldable like so
except of course still keep the functionality of hiding things
As expected, it half works on array
yours you mean?
Yep
with 'half' you mean you still see count and the name?
cause I had that issue earlier today
To deal with array, you either need to write an Editor, or wrap the array in a class
Exactly
In your case, you already wrapped your array in a class
Isn't TestThing the wrapping class?
Members of a class are supposed to be foldable
oh like that
yes
which is what I want for when it is an element in an array, but not when it is not
To be honest, I did not understand your statement here
https://discordapp.com/channels/489222168727519232/533353544846147585/733445687110533131
"You want it to be foldable like so" (everything is showing),
"except of course still keep the functionality of hiding"
So... Do you want to hide or show? I'm quite confused
in that screenshot all fields of TestThing are shown
Oooooh, you are talking about flattening the Class in an array, but keep the parenting when not in an array
while in the screenshot before that (when it was part of an array) only the fields that should be drawn were drawn
Show me your PD then
yes exactly
It's suppose to be easy
sorry for being confusing 😅
You have a propertyPath
If the path contains an "array member", you flatten
end of the story
the drawer is > 2000 chars
no it is not as simple as that
I know how to detect when it is in an array or not. I don't know how to make the foldout work
Please be very explicit
I'm getting confused
Which foldout?
Because you got few
https://discordapp.com/channels/489222168727519232/533353544846147585/733445687110533131
like in this screenshot
I see 2 foldouts
showing \🔽 Test Thing
because in the current implementation, it draws it like this (indentlevel 0 and no 'Test Thing' label nor an arrow)
that one has both a TestThing and a TestThing[] field
public TestThing testThing;
public TestThing[] testThings;```
the first three fields shown there (Foo, Frames, Always) are part of the testThing field
but they're not indented under a Test Thing label
am I making sense or am I only making things worse?
but they're not indented under a
Test Thinglabel
@austere sun They are not?
I would have said they are
each box is a TestThing instance
Yep, in this case, they are flatten and I see the indentation is wrong
But in your other picture, under the Test Thing label, they are indented
yes because that layout is what I want to mimic with my current drawer when it is not in an array
this is how I want it to look
Line 89, add a check to know if it is in an array.
If yes:
get properties right under.
Else:
Keep as is
oh so you mean instead of defaulting to the array drawing, instead default to the normal drawing?
If I'm not wrong, you gathered the "props" by looking up the fields.
yes
All your drawings are suppose to have the parent fold
I dont even see how you flattened it
the property that gets passed in the InitializeProps method is of type TestThing
so then the props are all the fields of a TestThing instance
Oh yeah...
and then in OnGUI I loop over the props and draw a prop iff it should be drawn
oh so you mean instead of defaulting to the array drawing, instead default to the normal drawing?
@austere sun So basically, yes
If you detect that TestThing is not in an array, you just default drawing
but the default drawing won't suffice
How come?
that'll ignore the DrawIf attribute
yea xD
Ok ok
Line 19, insert the drawing of "property" if not in array.
It has an "isExpand"
And update your GetPropertyHeight accordingly
XD
but what is "the drawing of \"property\""
You have your TestThing which lies in argument "property"
yes
EditorGUI.PropertyField
ah
and of course, the last argument as false
(to not draw children)
I'm not sure 100%
but if you used my ShowIf attribute given above
Your code would have been much smaller
As PropertyField would handle hiding automatically
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
this.InitializeProps(property);
EditorGUI.BeginProperty(position, label, property);
int y = 0;
if (!property.propertyPath.EndsWith("]")) {
EditorGUI.PropertyField(new Rect(position.x, position.y + margin + CalculateYPos(0), position.width, EditorGUIUtility.singleLineHeight), property, label, false);
y++;
}
foreach (var propName in this.propsOrder) {
SerializedProperty prop = this.props[propName];
if (this.ShouldDrawProperty(prop)) {
EditorGUI.PropertyField(new Rect(position.x, position.y + margin + CalculateYPos(y), position.width, EditorGUIUtility.singleLineHeight), prop, new GUIContent(prop.displayName), true);
y += this.GetPropertyLineHeight(prop);
}
}
EditorGUI.EndProperty();
}``` so like this?
but yours doesn't work correctly for arrays
looks promising
What is confusing you is this:
ShowIf would apply on members of TestThing.
not TestThing itself
but I need to change the height method as well, but not sure to what
no I know that
oh wait
I wait
As PropertyField would handle hiding automatically
what do you mean by that?
how does it automatically handle hiding
What is confusing you is this:
ShowIf would apply on members of TestThing.
not TestThing itself
This
oh yeah but the problem is that attributes on fields that contains an array apply to the entries of the array rather than the array itself
But this attribute is not on array fields, but on members of the array fields
shit you edited XD
Oh yeah I forgot you had the member "Frames"
Forget it
yeah xD
I don't know who the fuck made this insane mistake and not let us an option to handle it
Yes
I agree
I'm not sure how I need to change the height method
And even apologies in the changelog...
so they know it's bad and still did it? weird
well the height method would be the same as ongui
They just wrongly coded it and fixed it...
So freaking sad
OMG I GOT IT WORKING! 😄
🙂
thank you so so so so much for your time!
Do you understand why I said you were far from the truth?
https://discordapp.com/channels/489222168727519232/533353544846147585/733442613788803072
UI had nothing to do with your issue XD
I mean that's more about how they structured that repo that im unfamiliar with
GUI maybe
In the mean time, I hope you will optimize your PD
Because yours is insanely heavy
The last ToArray() is useless 🙂
If you work on a laptop or light desktop, or a lot of elements in your array
you will definitely feel it
what's a lot of elements?
actually more than once because of how sucky unity is
it probably happens once every frame
Just a few scroll
and you might feel it
give it a try
put 20 elements
and scroll it
20 is butter still
100 is a bit laggy, but not too bad tbh
Just the thing that you need to understand
PropertyDrawer are generated by the Editor, which is done by the Inspector in your case
I'd say 100 and scrolling is 45 fps
Every single frame, you will InitializeProps
yea I know that
This can be put in cache
oh?
You need to cache the properties and their conditions
When you GetPropertyHeight (Which is called right before OnGUI)
You check all the conditions and calculate the height
From it, you can populate the list of props to display for OnGUI
OnGUI you just render
End of story
oh so you're saying only keep the InitializeProps call on GetPropertyHeight?
around what?
Caching the props, conditions
I'm beginning to become a bit slow (it's 1:15am)
Populating the OnGUI in GetPropertyHeight
Caching the props, conditions
like in a static dictionary?
So Initialize() runs once and after you only check what you gathered already
no no, don't use a static for that
as I explained above
PropertyDrawers are generated by Editor
If you have many TestThings
You will have many PD
Maybe static can work, if you know things are not going to change
But since you are saving the SerializedProperty in there
It won't work
I am half following half confused
is Initialize() a method called by unity?
No no Initialize() was a short for your InitializeProps()
forget it XD
that's not how I work 😝
I'm really curious to know how to avoid making new property drawers each frame though
can I message you tomorrow about this?
So apparently if you have ExecuteInEditMode and an OnDestroy then OnDestroy gets called after the unserialized state is thrown away upon entering playmode 🙄
I want to make a private variable in one of Unity's types serializedfield but I have no idea where to start, I've been told I need to use reflection
Can anyone assist me?
Hmm im still not able to do this.
Basically im doing a download image of many files (hence why im making an editor script)
I use the async UnityWebRequest, works
Texture2D is saved to project, done
Then i wanna save it also as sprite. I do this immediately after File.WriteAllBytes
aimp.textureType = TextureImporterType.Sprite;
Line 2 gets nullref bcoz line 1 couldnt find it. Ok then
So also added AssetDatabase.ImportAsset(path); and await Delay(1000) (this is such a hack...)
But same nullref.
So how exactly do i know when an asset is imported, or when can i actually do AssetImporter.GetAtPath(path); ?
You want to make a field that's not serialized in a class you don't control serialized? @queen wharf
Does the type of the field even support serialization?
What type is it?
GameObject
And what field?
Sorry, might be a tad ignorant, GameObject is the field?
That's the type, not the field
That's already serialized
You mean you want to see it in the inspector
Yes, sorry for misusing a term
You'll need to create a custom editor that shows it
This is the default one https://github.com/Unity-Technologies/UnityCsReference/blob/master/Modules/TilemapEditor/Editor/Managed/TileEditor.cs
You probably want to base it of off that
I see, I'm not unfamiliar with C# but im completely new to this stuff
where should I start in having any idea how to do this
I see, thanks
so the end result would be the exact same as my current unity except when im looking at a Tile in the inspector it will show the type i want?
It depends 😛
Often it's either not easy or possible to replicate it a 100% since they might use internal APIs
Reading this guide
I still don't know how to access the tile variable im looking for
i understand most of this stuff, but it relates to making a new thing, and not editing an existing thing
Yes there's no documentation on editing an existing thing
It relies on your own knowledge
I'd just try to copy that class that I linked
Change the class name + namespace
And see what errors your run into
Ok got it to work
But this is what i mean tho.
I changed the type like so:
aimp.textureType = TextureImporterType.Sprite;
And now it's different than how normal Texture2D asset type changed to Sprite. This one is a single asset without that subchild sprite asset
Compared to this (normal Sprite asset)
So, does Unity actually create a Sprite sub-asset and parent it to the Texture2D asset, when changing type to Sprite in editor?
just changing that doesn't apply it
I would use scriptable serializedobject to modify that field, apply that, and then reimport the asset
the sub asset is created by the importer when the asset is imported
SerializedObjects?
yes, sorry
Happens, they're very confusing
It seems the most correct way is to do SpriteImporter : AssetPostprocessor.OnPreprocessTexture override rather than guessing when after/before WriteBytes/.Refresh/.ImportAsset etc
Hey everyone, dose anyone know if you can add bones to things in proBuilder?
So I tried to figure out how to add a menu option to the context menu in the hierarcy but I can only find really old answers and they don't seem to work ._.
using UnityEditor;
using UnityEngine;
public class PrefabContextMenu : EditorWindow
{
[MenuItem("CONTEXT/GameObject/Replace Prefab", false, 0)]
public static void ReplacePrefab(MenuCommand command)
{
Debug.Log("test");
}
}
What do?
I think that last number passed to MenuItem specifies position in the menu. But the "sorting values" of each menu item is spaced out quite a bit, so some guesswork is needed to get the right number. Try passing something huge like 1000 and see if your menu item moves to the bottom of the menu. Then try values in the middle till you figure out the right value
oh I see, yeah not sure.
your class extends EditorWindow but the example here extends MonoBehaviour.
https://docs.unity3d.com/ScriptReference/MenuItem.html
It's worth a shot
Shouldn't matter
Hm okay
Did you try it and did it work? If not I have another idea
it's accepting a parameter. The examples I'm looking at don't accept a parameter
...but now I see others that do.
you could also try adding the menu item to a different menu, just to be absolutely sure that it is able to appear, just now where you want
not*
Well if I remove the "CONTEXT" part and only go with GameObject, it does appear in the menu, though it also appears in the GameObject menu in the top-left
Which isn't very conducive to its function because it's context specific
If you read through the conversation here you'd find that this supposed "fix" does not fix it.
[MenuItem("GameObject/Test9", false, 0)]
static void testFunc9(){
}
This just makes it appear in all GameObject menus
I want it to only appear in the hierachy when I right-click a gameobject
I'm curious if anyone has any tips on stepping through / debugging UI Elements code to see why, for example, a mouse click is not being handled in the way you expect.
In my case I essentially have a custom Button that is embedded in a Foldout header, but when I click the button, it causes the Foldout to expand/contract. I want the Button to block clicks from going through to the Foldout header underneath.
Does any of you know how to use this method: EditorGUIUtility.GetObjectPickerObject() ?
I don't really understand how to use the Object that it returns to get the GameObject that was picked with this:
[MenuItem("GameObject/Replace GameObject", false, 0)]
public static void ReplacePrefabCall(MenuCommand command)
{
currentPickerwindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
EditorGUIUtility.ShowObjectPicker<GameObject>(null, false, "", currentPickerwindow);
}
public void OnGUI()
{
if (Event.current.commandName == "ObjectSelectorUpdate" && EditorGUIUtility.GetObjectPickerControlID() == currentPickerwindow)
{
currentPickerwindow = -1;
ReplaceObjects(EditorGUIUtility.GetObjectPickerObject());
}
if (Event.current.commandName == "ObjectSelectorClosed")
{
currentPickerwindow = -1;
}
}
private void ReplaceObjects(Object pickedObject)
{
GameObject[] selectedObjects = Selection.gameObjects;
if (selectedObjects != null && selectedObjects.Length > 0)
{
// how to use pickedObject ??
}
}
(Sorry, I don't know the answer to your question, OmniOwl)
I'm thinking that I will need to clone the UIElements source code and copy the Clickable / PointerClickable / etc. manipulators into my project, rename them slightly, and use them so that I can step through the code and see why my clicks aren't handled the way I expect.
@tulip plank if you go to about and type ‘internal’ magically a ui toolkit (aka ui elements) event debugger will appear in I think Window->Analysis
I realise that legit sounds like I’m making it up but I’m not 😂
It’s still not easy to track down issues with events (I totally failed to even using this tool) but it might help
Very cool, I'm taking a look. My other option was to just create my own versions (via copying from reference source) of each of the manipulators, etc. that I needed to debug.
Well you certainly mostly can - just copy the package into your project’s packages folder
Oh I was wondering that, yeah... would it conflict with the... non-package library, though?
If it detects a local project version it uses that instead of the one centrally cached
Oh interesting, I wasn't aware of that.
Yea - really nice 👍
Oh, another maybe-dumb question: If I look for the reference source online, it says it's for Unity 2020.something. How do I find the 2019 version (which is what I'm using)?
Oh nevermind, clearly I can select the branch in GitHub
Does anyone know of an open source sprite packer?
http://free-tex-packer.com/
not tested
About Free Texture Packer is an open source tool that allows you to pack multiple images into one atlas for you games or sites. Key features Totaly free Open source Multiple platforms (Windows, Linux, MaxOS, Web) Console tools (gulp module, grunt plugin, webpack plugin, cli) S...
Anyone know why AssetModificationProcessor.OnWillMoveAsset ain’t being triggered??
i think restarting unity fixed it for those who encountered the same issue
when i do a EditorGUILayout.BeginVertical(); how do i get the position, so that I may draw a control using a Rect()?
nvm, it's just position
any of you know how to make this work? ```cs
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
[CustomEditor(typeof(SkinsChanger))]
public class SkinsChangerEditor : Editor
{
private VisualElement _RootElement;
private VisualTreeAsset _VisualTree;
// This function is called when the object becomes enabled and active.
void OnEnable()
{
_RootElement = new VisualElement();
_VisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("skinChangerEditor.uxml");
}
public override VisualElement CreateInspectorGUI()
{
return _RootElement;
}
}```
the uxml:xml <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:VisualElement class="Title"> <Style src="SkinsChangerEditor.uss" /> <ui:Label text="Skins Changer" /> </ui:VisualElement> <ui:VisualElement> <Style src="SkinsChangerEditor.uss" /> <uie:PropertyField label="Momoo Flat C"> <uie:ObjectField label="Momoo Flat C" binding-path="momooFlatC" /> </uie:PropertyField> </ui:VisualElement> </ui:UXML>
and USS:css .Title { font-size: 32px; justify-content: space-around; -unity-text-align: middle-center; border-left-color: rgb(126, 126, 126); border-right-color: rgb(126, 126, 126); border-top-color: rgb(126, 126, 126); border-bottom-color: rgb(126, 126, 126); border-bottom-width: 4px; border-top-left-radius: 20px; border-top-right-radius: 20px; background-color: rgb(233, 138, 138); }
my goal is to be able to modify this script:
i tried following this but doesn't seem to work: https://docs.unity3d.com/ScriptReference/Editor.html
so, i'm trying to find a solution but i'm getting this result:
that is how far i managed...
pretty sdure i did something wrong 🤔
it worked but i get it:
multi-object editing not supported... probably due to the fact this script is in the prefab mode?
is this where it should be for _VisualTree.CloneTree(_RootElement);?
oki
but still not working...
same message for "multi-object editing not supported"
i just figured why i did it wrong....
i changed it to this: ```cs
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
using System;
[CustomEditor(typeof(SkinsChanger))]
public class SkinsChangerEditor : Editor
{
const string resourceFilename = "SkinsChangerEditor";
public override VisualElement CreateInspectorGUI()
{
VisualElement customInspector = new VisualElement();
var visualTree = Resources.Load(resourceFilename) as VisualTreeAsset;
visualTree.CloneTree(customInspector);
customInspector.styleSheets.Add(Resources.Load($"{resourceFilename}-style") as StyleSheet);
return customInspector;
}
}```
it worked but....
it's gone
Hey, So I'm making a vr parkour shooter thing and after making a indoor level in probuilder and testing it, my character doesn't jump anymore when on the floor, only on slopes, do Ontriggerenter methods not do well with rooms were the faces are flipped inward?
Hello, is possible to override unity gameobject context menu actions, like copy, duplicate etc. I don't like the fact that when I duplicate something name "something1" I get "something1(1)" and I would like to get the normal "something2". I want to achive this using a context menu for the gameobject. The issue is that the static function is never called when I click "duplicate" . cs [MenuItem("GameObject/Duplicate %d", false, priority = -100)] private static void DuplicateGameObject() { Debug.Log("heii I am called"); foreach (GameObject gameObject in Selection.gameObjects) { string name = gameObject.name; int number = 0,i = name.Length - 1; // "Hospital" while (i >= 0) { bool isNumeric = int.TryParse(name.Substring(i), out var numberTest); Debug.Log(name.Substring(i) + " " + isNumeric); if (!isNumeric) break; number = numberTest; i--; } Debug.Log(number); number++; string duplicatedName = name.Substring(0,i + 1) + number; Transform parent = gameObject.transform.parent; GameObject duplicatedGameObject = Instantiate(gameObject, parent, true); duplicatedGameObject.name = duplicatedName; } }
I would use a shortcut attribute https://docs.unity3d.com/ScriptReference/ShortcutManagement.ShortcutAttribute.html
that way you can rebind it in the shortcuts settings
just as you can rebind the default one
But I think duplication probably isn't as simple as that
and also affects many other items across Unity
so I would probably try to use https://docs.unity3d.com/ScriptReference/EditorApplication-hierarchyChanged.html instead
and just remove it via that
back, i tried again that ui builder but it appeared it's not working.....
and i get this result:
even though i followed this: https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Editor.html with exactly how they did
that is the result
and it's annoying that it didn't display anything...
i did drag the script myplayer in the gameobject it became invisible as a result
as proof:
i found that really weird
I want to set a hotkey for a custom EditorTool. Couldn't find it in the shortcut editor so I created a menu item that does the switching, and that showed up in the regular shortcut editor and it works ... except in the script I switch by just doing Tools.current = Tool.Custom; which only works because I only have one custom tool right now. Couldn't find a way to specify which one specifically to switch to, is that even exposed in the API? (Or am I missing something re: just directly setting a shortcut for a specific custom EditorTool without the [MenuItem] script middleman?)
Has anyone ever made a unity test that includes ink (https://www.inklestudios.com/ink/)? We're trying to bring on new programmers for our team, but we're having a difficult time coming up with a unity test that incorporates ink
Is there a way to rename components with an addon
When I have 5 colliders on an object it’d be nice to name them so I know which is which
@shrewd kindle https://assetstore.unity.com/packages/tools/integration/ink-unity-integration-60055 have tried to add it?
When I have 5 colliders on an object it’d be nice to name them so I know which is which
@woven knot I developped such a feature in one of my prototype tool (NG Flow Inspector)
If you would like to give it a try get NG Tools Free
It's in there
@idle anvil we already have it added in our Unity build, right now we're trying to bring on programmers that know how to build custom functionality for the integration
ah that, there is a github for it, i think
it's best to wait a little because the team have something new to be announced
also, they have official discord server
I kind of doubt that plugin is big enough to have people skilled in it that are looking for a job
I'm trying to modify the MemoryProfiler package (the new stuff, not the old plugin by the same name) to call some code in Assets/ but it gives the "name 'foo' does not exist in the current context". Both the profiler code and the code I'm trying to call are in Editor/ folders. Is it at all possible to do this or am I out of luck?
You probably need references in the AsmDef
Which means the code I'm trying to call also needs to be in an assembly, right?
In an AsmDef yes
i honestly have no idea what is the meaning of it....
even though there is no error in the code:
ah?
is that so?
even though it's this way:cs public override VisualElement CreateInspectorGUI() { VisualElement customInspector = new VisualElement(); var visualTree = Resources.Load("Assets/Resources/Scripts/Editor/Skins/SkinsChangerEditor.uxml") as VisualTreeAsset; visualTree.CloneTree(customInspector); customInspector.styleSheets.Add(Resources.Load("Assets/Resources/Scripts/Editor/Skins/SkinsChangerEditor.uxml") as StyleSheet); return customInspector; }
Sorry if this is wrong chat, but I'm using a Cinemachine Free Look camera that I only want to rotate if the player is holding down an input. In other words, I need it to continue "Follow" and "Look at" at all times but only rotate around situationally. Is there an option so I can script this or am I using the wrong kind of camera?
How you guys make enum showed in inspector that I can switch value of it? atm im using
EditorGUILayout.PropertyField(AItype, new GUIContent("AI type"));
but I cannot change the value of it from inspector, it stays same.
Did you apply?
is there a way to find all Texts at editor time from prefabs and scenes then change all the text components to TMP?
Find all GameObjects in the AssetDatabase and check if them or their children contain a Text component
hmm let me try ty
Wrong channel
#💻┃code-beginner or #💻┃unity-talk but I doubt you'll have much more success there tbh
Sure but this channel is about developing your own extensions
Not using them
I see, sorry m8
thank you
Hi Guys, anybody know how to load this waveform texture from the imported audio ?
I'd look at the decompiled code
decompiled code?
the source code to the C# side of the editor is pinned to this channel
ooh
I am trying to make an int matrix of a scriptable object editable in the inspector. So far so good but the values keep resetting when I click play and I have no idea why. Am I missing something obvious here?
https://hatebin.com/zysjizyfqu
how would that work with a matrix
How can i make a string list popup? Using EnumField or something else?
I used to do this in IMGUI:
animationAttacker.intValue = EditorGUILayout.Popup("Animation Attacker", animationAttacker.intValue, animationListArray);
hi how to use opengl es3 instead of 4.5 in the editor i tried alot but its not working
How to add this animation its going in as a PNG as it is
is it possible to make an attribute and have a custom inspector for every class with that attribute?
like [CustomInspector] public class MyClass : Monobehavour { }
i have multiple classes that i want to have the same inspector and i don't want to recreate an editor class for each one
@solar basin in your inspector either [CustomPropertyDrawer(typeof(blah), true)] or [CustomEditor(typeof(blah), true)] - i.e. the second param should do what you want
Yeah should use a shared base class
like this? is there a way to do it without inheritance and just attributes?
I don't think you can do that
But you can make a CollectionAuthoring base class and write an editor/propertydrawer for that
And then make your ItemCollectionAuthoring inherit from CollecitonAuthoring
i know its possible to make attributes for properties, but i want to do it for the whole class, not just one property if possible
??
removing mistakes
Yes you can for a whole class, just not a MonoBehaviour
ah
I found these in the 2020.1 patch notes. Both are very nice imo!
TypeCache was kinda buggy for me, but they are interesting API nonetheless
Oh really?
yep, it did not want to work after a compilation, during the very first frame
Bug reported of course, but lost my attention since then
Ah. Well if it works I think it would be real handy.
I guess they fixed it since
Should be fine
give it a go 🙂
In my tests, it was interestingly faster
Editor: Introduced PreviewSceneStage. Implement custom stages by inheriting from this class. Finally! 😄 I remember trying to do this my self, had to use reflection and stuff and it still didn't work right.
genarTheDevheute um 16:47 Uhr
Tried to install "Localization" Package from unity... getting this error "Library\PackageCache\com.unity.localization@0.7.1-preview\Editor\Settings\LocalizationEditorSettings.cs(376,24): error CS1061: 'BundledAssetGroupSchema' does not contain a definition for 'BundleNaming' and no accessible extension method 'BundleNaming' accepting a first argument of type 'BundledAssetGroupSchema' could be found (are you missing a using directive or an assembly reference?)
" Any ideas ?
I've got some BeginHorizontal/EndHorizontal, in between, I just write text, however when I start the 2nd block, i have a large vertical space inbetween the blocks, any idea?
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space(60);
if (GUILayout.Button("Use this Directory"))
{
AssignDirectory(gameDirs[0]); //has no visual oputput
}
EditorGUILayout.Space(100);
EditorGUILayout.EndHorizontal();
GUILayout.Label("This line is lower than it should");
EditorGUILayout.Space does it even exist? O_o
What version of Unity?
We never know, often people in here does not even realize it is not even compiling
please don't ask me questions for noobs
it's to do with the Space fn, but what's the alternative
For your information, EditorGUILayout.Space appeared in 2019.3
i'm at least using that version then
Your issue is this one:
Next time, stay polite and dont expect us to be god gifted and read into your mind
Just use GUILayout.Space and you are good to go
use a custom space fn you wrote above?
Nope nope, the function I showed you is the one implemented by Unity
That's why you see a 60px height spacing
soon as I add the Space() it adds vertical space in the horizontal block
Because the 2nd argument of GetRect is height
Because you are using EditorGUILayout.Space
Are you sure I should talk to you like an expert?
appologies, there are a lot of people who expect anyone who asks questions here to be noobs
No worry. We need to measure people behind their questions, to adapt our solutions/advices/tips
the normal responses i get are jsfg, which i've already done
jsfg? O_o
GUILayout.space works fine
🙂
now i feel like a noob, lol
Don't worry, Unity implementing Space as a square is already making them noob
I will never get how they think/work...
thank you
have you got a EditorGUILayout.BeginHorizontal(); EditorGUILayout.EndHorizontal(); around your button?
the post was deleted, meh
is there a way to specifcy the location of the BeginHorizontal relative to the height?
i've got some controls that add or remove a line above it, causing the dialogue to jump up and down & not sure how to fix it
You mean the space between a block BeginH and the one above?
Space() is a good way to insert space
You just need to remember if you are horizontally or vertically drawing
i've got a begin/end block above it, that is not always dispalyed, sometimes adding a space of 20 vertically
won't the space also be relative to what's added above it?
i can just add an else condition to add a space instead if nothing is displayed i guess
out of curiosity, is there perhaps a way that i can specify the vertical position of a beginHorizontal with a Rect perhaps?
Yep
Use Space() to define the offset or space.
Then use GetRect with the right style and options
Or simply go Space() with the height you want, and draw using EditorGUI and not EditorGUILayout, but this implies that you "master" GUI
yeah, mastering gui is a stretch
are you talking about EditorGUILayout.GetControlRect?
This one is a good pick
But this one is made for a nice & good display of "controls"
Like TextField, Float, Int, string etc...
I tend to use GUILayoutUtility.GetRect() for better control
thank you, i'll read up on that
This last doesn't take into account the margin space and other stuff
Which is good or not, it depends on what you to display
Any idea why I'm getting extra spaces between these variables? Here's the code: https://hatebin.com/gryhmadqoz I've tried setting their height with GUILayout.Height, with no effect
The code provided is not sufficient to help you unfortunately
And moreover, I guess you are using Odin
Maybe something is messing up over there
What other code do you need?
You dont override GetPropertyHeight, I would say the default height is 16 pixels
Maybe your MB Grass is having attributes, or anything that can bug the UI
Just removed Odin, no other attributes in project
Show us Grab then
Grab?
Now it's just not showing anything : /
And getting this for some reason now too:
Grass sorry
?
the MonoBehaviour
Hum, ok
Yeah
You can't use those
EditorGUI is for manual drawing
EditorGUILayout is for automatic drawing
PD provides you a position (Rect), to draw in
With this position, you need to use EditorGUI
Makes sense why it's off then
Because if you use the Layout, you are going to draw in the layout world, which would be at the very top of your window
Could I swap this to a custom editor or something, and keep using GUILayout? I'm confused on the differences there
Unfortunately no
PropertyDrawer only provides a Rect
So, you are suppose to work with Rect manually
Hum, ok. Thanks
But you can use GUILayout.BeginArea to switch from manual to automatic
To easy your life
Ah, haven't heard of that one. Will look into it. Thanks
But in reality, you might encounter futur bugs
BeginArea is nice, but truly, it can bring disasters upon you
🙂
I warned ya
Yeah, sounds about right
is there a way to clone a scriptableobject?
Hey anyone got time to help me?
I have this waypoint script but I havent manage to fix it the way that when Im making new point by pressing button it would update positions that it would always take last position from last point + offset position.
So simply what I want is that it would spawn correct place when I have moved parent object.
Heres de editor code: https://pastebin.com/AU4R9QYG
well there is no really code in it but sure:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Waypoint : MonoBehaviour
{
public int waypointCount;
public List<Transform> Waypoints = new List<Transform>();
public GameObject Point;
public float Radius = 1;
}
just make the position you track be local
and transform it to world space if you want to
using TransformPoint
erhm.. okay?
i'm confused as to what you want actually
so say i had my first waypoint at 0, 0, 0
i move it to 1, 0, 0 and press create waypoint
what's supposed to happen?
like I said, I want created point always be created from last point + offset.
these created points are children of gameobject what holds the script.
so if you move your parent object and try create point, it will spaw in wrong place.
you're using world position, just use local, it will fix all your issues
So I put it like:
lastPosition = point.transform.localPosition; ?
yes, and then set it using local position too
Welp, I can tell you sure that it wont work but lets give it a try.
if it doesn't work you need to explain exactly what you want to happen a bit better
I dont know how I can explain it any better.
- When ever I press '' create waypoint " button, it makes new Point and makes it child of this game object.
- When making new point I want it always spawn from last point + offset. no matter how much I move Parent object, it should always spawn from last point + offset.
I will try now that localposition what vertx mentioned but I doubt it will works since I have tried it before.
what is the offset?
that "lastPosition" vector
just give me the scenario that i was trying to understand with
- new Vector(0,0,5)
you have your first waypoint at 0, 0, 0 on the parent game object
you move it to 1, 0, 0
you press the button
what's supposed to happen?
did you move child (point) or parent?
well no matter did you move parent or child self, next point must spawn from that last point + offset
give me numbers man
you see FIRST point gets created from parent position
next Point gets created from last point
when you press the button again
I already said
like specifcally...
next point must be created from last point what already exists
and now I shall show your "localPosition" result
cuz i dont understand what you mean by last point + offset
offset means nothing to me
you have a gameobject "A" at 0, 0, 0
you press the button.... it makes it at 0, 0, 0
"B" at 0, 0, 0
you move A to 1, 0, 0
it creates C where
etc etc
[Press button] > Create Point > Set position of it to Parent
[Press button again] > Create Point > Set position of point to earlier point + offset position
Give me some vector positions in your example
you dont need that vector x)
so i know what the heck you mean
it doesnt matter in what coordinate that object is in numbers
Jesus..
i dont think you're understanding why i'm asking for the vectors
it's because offset is relative
Parent object in 0,0,0
Press button > Create Point to SAME POSITION AS PARENT SELF 0,0,0
Press button again > Create point to SAME POSITION AS EARLIER POINT SELF + Offset position ( 0,0,5) 0,0,5
I move parent to 5,0,0
Press button again > Create point to SAME POSITION AS LAST POINT SELF + offset position (0,0,5) 5,0,10
etc.
ant localpositionin didint work.
not top of parent, what I meant that next point what gets created will be set to same position as last point + that 0,0,5.
But you said you moved the parent to 5, 0, 0 and the result is 5, 0, 5
local position would work fine
but it doesnt work
you'd just need to initialise your weird first offset - which I assume you're doing in your current implementation
It is possible that lastPosition needs get reseted because it throws weird positions for points when they are created
So I dont honestly know what to do with this
sorry I still don’t understand what you want to happen. Sounds like vertx knows
What you can do instead of keeping a last position vector is to reference the last point created
Vector3 newLocalPosition = Waypoints.Count == 0 ? Vector3.zero : Waypoints[Waypoints.Count - 1].localPosition + offset;
newWaypointTransform.localPosition = newLocalPosition;
Waypoints.Add(newWaypointTransform);```
just something like that
So Waypoint lastPoint
And then do: point.transform.position = lastPoint.transform.position + offset ;
Same idea vertx had. Minus the list
😫
?
my brain hurts, im too sleepy to think.
Yea take a break
You just need a reference for previous and next waypoint in your waypoint script.
Then you go like:
Waypoint currentWaypoint;
void CreateWaypoint()
{
Waypoint newWaypoint = Instantiate(prefab, currentWaypoint.position + offset, currentWaypoint.rotation) as Waypoint;
currentWaypoint.nextWaypoint = newWaypoint;
newWaypoint.previousWaypoint = currentWaypoint;
currentWaypoint = newWaypoint;
}
Does anyone have a use for a multi-platform build script?
hi guys i got a issue with my Debug tools , its supposed to take all the created scenes but it don't want to ```cs
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
class DebugTools : EditorWindow
{
string SceneName;
[MenuItem("Window/Scene Opener")]
public static void ShowWindow()
{
GetWindow(typeof(DebugTools));
}
void OnGUI()
{
//SceneName = EditorGUILayout.TextArea(SceneName);
foreach (SceneAsset scenes in Resources.FindObjectsOfTypeAll<SceneAsset>())
{
if (GUILayout.Button("Open Scene : " + scenes.name))
{
EditorSceneManager.OpenScene(scenes.name);
}
}
}
}```
@onyx harness yes
Because Resources doesn't know them yet
You have to load them all
@digital briar
Then only, Resources will ackknowledge them
You should use AssetDatabase to find them
It is also a finer solution
so i use AssetsDatabase with LoadAssetAtPath?
@waxen sandal do you know what is a filter? whats thats mean
because i've tried like thats : string[] Scenes = AssetDatabase.FindAssets("",new[] {"Assets/Scenes"});
but i don't understand the filter
try "t:scene"
Hi, I've been trying to put together a polymorphic property drawer of some sort that I need for work. It's been an absolute nightmare. My current solution is to serialize the objects to Json strings along with their types, it seems it works so far (I've thought that several times though). Now I'm having more problems with the drawer itself.
{
var collection = ((objectInstances)EditorHelper.GetTargetObjectOfProperty(property)).objects;
var buttonRect = new Rect(position.x, position.y, 150.0f, position.height);
if (GUI.Button(buttonRect, "test"))
{
collection.Add(new baseObj());
property.serializedObject.Update();
Debug.Log("added object to list");
}
Debug.Log(collection.Count);
for (int i = 0; i < collection.Count; i++)
{
Debug.Log("drawing object " + i);
var instance = collection[i];
var userTypeChoice = (objType)EditorGUILayout.EnumPopup(instance._type);
if (instance._type != userTypeChoice) Debug.Log("request new object type");
switch (instance._type)
{
case objType.none:
break;
case objType.first:
break;
case objType.second:
break;
case objType.deep:
break;
default:
break;
}
}
}```
It does the expected stuff, I can add an object to the list and the enum popup works. Until you close that inspector. When you reopen it only draws the button and throws "ArgumentException: Getting control 1's position in a group with only 1 controls when doing repaint" . I've looked around and it is suppose to happen because OnGUI is called several times a frame and changes to the number of controls makes it loose it. But using the debug message, it seems the code steps through it three times in the exact same way so I don't know how it loose one of the controls (without mentionning that drawing the added object inspector when it's added to the list should trigger the error, but doesn't)
Am I missing something important here ?
why my message is not here
I've seen flicker in and out several times
me too
Because you need to use hastebin to post code
You can't paste big chunk of code, dont repeat or you will get an auto temporary ban
oh
Just a mute I think
@graceful gorge Dont use EditorGUILayout in PropertyDrawer
Yeah i just noticed it
It removed the exeption, still doesn't doesn't draw the list object
so it's not working can u guys help me (line 24) https://hastebin.com/pamafiguve.cs (thats my first time coding the editor)
well i've tried to convert it to string but it's not working and i know why but how can i convert the var to a EditorSceneManager scene
It removed the exeption, still doesn't doesn't draw the list object
@graceful gorge Maybe because you did not adapt GetPropertyHeight?
@onyx harness if you are talking to me , yes the list is working and the name contains the path
wait
i'm stoopid
um no i doesn't work
@graceful gorge Maybe because you did not adapt GetPropertyHeight?
@onyx harness it's a popup, it's not linked to any property directly, unless I misunderstand you. It also manages to draw it just fine when you add the object to the list for the first time
Really need more context on both your issues, what exactly is failing
We're just guessing at potential issues here
@onyx harness it's a popup, it's not linked to any property directly, unless I misunderstand you. It also manages to draw it just fine when you add the object to the list for the first time
@graceful gorge I'm sure you missed my point, and I would bet it was previously an illusion
He is right, show us some code
https://hastebin.com/raxijatize.cpp That's the whole thing
@onyx harness is right, you need to override GetPropertyHeight on your PropertyDrawer
https://hastebin.com/raxijatize.cpp That's the whole thing
@graceful gorge Yep, this is what I thought. Without overriding GetPropertyHeight, your PD would always be 16px as height
I guess, your field objectInstances was the last of your MonoBehaviour?
it's stored in a scriptable object but yeah
Oh yeah I should have thought about it
Because with "Add Component" at the bottom, you would have seen it, the issue
So you just need to override GetPropertyHeight
You are absolutely right, I put the button at the bottom and now it straight up doesn't display anything. I'm going to implement an override I suppose I need to add the heights of all the stuff I'll display? Still kind of baffled that it initially worked. You both have been a really big help, you can't imagine
Yeah just add everything together
You can use EditorUtility.SingleLineHeight
Be sure to account for potential expanders and stuff
Still kind of baffled that it initially worked.
@graceful gorge Told ya, an illusion 🙂
Worked like a charm
Hi, I'm trying to Instantiate a specific prefab on my project folder into the scene using a editor window.
In the documentation the example for PrefabUtility.InstantiatePrefab() Instantiates the selected GameObject on the Scene, but I don't want to select it, and just instantiate it from it's known path.
So far I'm stuck trying to use AssetDatabase.LoadAssetAtPath() to get the reference object, whatever I try, it seems to return null everytime, so I can't instantiate.
anyone know the correct way to do it?
this is what I'm doing
I'm trying to follow these documentations
This to get the Prefab
https://docs.unity3d.com/ScriptReference/AssetDatabase.LoadAssetAtPath.html
And this one to instantiate it
https://docs.unity3d.com/ScriptReference/PrefabUtility.InstantiatePrefab.html
this is what I'm doing
@brisk crest you forgot the extension '.prefab'
@brisk crest you forgot the extension '.prefab'
@onyx harness Ohh, that seems correct... I didn't noticed that, but I solved it overthinking it and using Find Assets to get the GUIDs Path, and then converting the GUID to AssetPAth XD
If it works, it works
Lol I added the .prefab and deleted the other method and it does work XD thanks 🙂
Hi!
What happened to ProjectFilesGenerator in Unity 2020.1?
It is not triggering any builds anymore. I'm using Visual Studio 2019.
Is it something to do with the new VS extension on the package manager?
Idk what that api is but there's a built in api
Yeah, thanks 🙂
A took a look into the code and found that too.
And sidenote, this OnGeneratedCSProject can return string, so you can entirely replace csproj contents.
Yeah, it works and looks like it's backward compatible ❤️
https://gist.github.com/Erdroy/4c5326034aa518ff2a5b291b8c3a07ba
Oh that's the one I meant to link 😛
There's also one that returns a bool to say if you "completed" the generation somewhere iirc
Ah, cool.
OnPreGeneratingCSProjectFiles
OnGeneratedCSProject
OnGeneratedCSProjectFiles
OnGeneratedSlnSolution
if I have a scriptableobject that has Sprite[] frames and float duration properties, can I then show a preview of the animation in the inspector?
Done manually, yes
what do you mean by manually?
You draw a sprite using GUI.DrawTexture
anyone know how to autosize editorgui labels?