Create Custom Unity Inspector Layout - unity3d

So I have seen a few of these scripts in unity and I am wondering how I can recreate it in my own scripts?
So I have a script the when a object is clicked, it will call a function on another script. I want to be able to pass arguments and much more but the Inspector got messy with a bunch of toggles, int fields etc.
Is there any way to recreate this sort of thing?
Not as much the Event type but the little function box instead. If that makes sense :)
Thanks!

The box you showed in that screenshot is an Event Trigger. There isn't any way that I know of that lets you separate the UI object from this underlying type. So there isn't a way to just draw the delegate box.. However, you can make a class based off of EventTrigger and then you can extend EventSystemEditor.
You can also make a class derived from UnityEvent in this fashion and it will show up with a function delegate box the way you wanted it to.
However, again, that just won't get you a drawing method that draws the function/delegate box for you. I don't know of a single way of getting Unity3D to let you do that.
You can check the entire list of GUI drawing methods:
https://docs.unity3d.com/ScriptReference/EditorGUILayout.html
https://docs.unity3d.com/ScriptReference/EditorGUI.html
But it's just not there.
I know that some people have managed to achieve similar effects with Inspector wizardy, recreating a similar aspect and functionality. I know FullInspector can do delegates in its inspector and you could check its source code to figure out how, but it could end up being a lot of work. Specifically serializing the delegate is hellish, so if you want it to serialize, I wouldn't even bother. I suggest finding a different path of minimal resistance.
Here's an alternative:
You can collect the methods in the class you're targeting via reflection and present them in a dropdown menu. Then once a method is selected you can again use reflection to see what parameters that method requires and use GUI functions to draw the appropriate fields required to receive those parameters from user input.
It's definitely possible, but again, I think that will take quite a lot of time to elaborate and you're better off finding a way of satisfying your requirements without this level of Editor GUI shenanigans.

Related

How does one create a component which can effect things outside of runtime?

So I want to make a custom component. One of the functions I want to have is the ability to create and modify set of points that make up a circle. For example, specify point count:10, and on field update, a circle made up of 10 triangles is drawn in the editor.
Then I want to be able to drag the vertices of the created circle. I feel like I might be able to do this during runtime, but I'm curious how to do it out of runtime. For example, the built in "Box Collider" component has a button that allows you to edit the collider size in the editor.
I looked around and can't find a resource - I feel like there has to be a place for this.
Thanks.
You can execute scripts like if you were in runtime using the [ExecuteInEditMode] annotation at the begining of your class.
Check out the documentation here
For the functionality you want, you have Handles, to manipulate objects properties.
Also you'll want to develop visual aids for your tool, so you can accomplish this using Gizmos.
Google "Custom Editors for Unity" - there's a whole section of the docs for this. You have a wide array of options, from the simple to the powerful.
I recommend catlikecoding's tutorials, that are clearly than the official docs, and take you through the process step by step.
One of them almost exactly describes your situation:
http://catlikecoding.com/unity/tutorials/editor/star/

Make MATLAB panels automatically rescale. (Not using GUIDE)

I have created a basic MATLAB UI (without using GUIDE). I basically have a bunch of panels for various things, (sliders, axes, text boxes, etc).
The one thing I would like to do though, it make it so that they scale properly, when I resize the figure. Right now, I painstakingly have to make a re-scale function for every button, panel, sub-panel, etc etc to make it rescale correctly.
Is there an easy way to simply automate the re-scaling here?
Thanks.
Use the GUI Layout Toolbox from the MATLAB File Exchange. I haven't personally used dynamic resizing functionality, but that's one benefit of using this package.
It functions much like using uicontrols, except you can't use the inspect tool on these objects.
EDIT: If you're looking only to do resizing when the figure itself is resized, set the Units property for all your uicontrols to normalized.
You could also use the builtin, but undocumented uigridcontainer and uiflowcontainer.
They have the benefit of e.g. allowing to set contraints, such that e.g. your pushbuttons don't get increased in size, when the full figure does. Check the link for some examples:
http://undocumentedmatlab.com/blog/matlab-layout-managers-uicontainer-and-relatives/

Android ListView-like scrolling WITHOUT the ListView

I've been Googling like crazy for a while now, and I simply can't find any answers to the question: is it possible to implement the Android List scrolling, without using an actual list UI?
I'm trying to make a grid of rectangles such as the kind you would find in a typical game app respond to finger movement in the same way that it does using Android lists (bounce on the bounds, the 'flick' effect, etc), but all of the approaches I've found involve over-complicated solutions involving extending the list, defining XML layouts, etc.
Would it not be possible to simply give an object variables for 'document' height, 'viewable' height and y-offset? I'm happy to give the delta (MS since last update) to the object on every update. It would also be good if the actual interactive region was also definable.
Additionally; are there strong advantages to using the ListView instead that I'm missing? I assume responsiveness comes into play, but I'm quite happily managing that manually at the moment.
Just use ScrollView directly, assuming you only need vertical scrolling.

Designing a TextCtrl which fills up the entire frame

I am programming with wxPerl and I was wondering how you would design it so that a textctrl, or really any component, would fill up the entire frame and resize with the window?
So far my attempts at researching this problem have led me to believe that potentially using the wxBoxSizer is the way to go but documentation for wxPerl is a little scarce..
Thank you all for any help
The documentation for the wxWidgets API is excellent and very comprehensive. wxPerl exposes most of the API in a stratightforward manner.
If a Wx::Frame object has only a single child window, the default size event handler automatically resizes the child to fill the frame.
If you have a more complex requirement then you can overload the handler or, as you say, write a sizer.

iPhone - At user event create objects in the view

I am new to iPhone programming, so I think part of the problem is that I don't know what I really want to google to find my answer. I am looking for a method that allows a user to draw a line on the screen. There is no guarantee that it will be straight, it can be curved or whatever. I was thinking that I could create some small square image, and then as they draw, place them into a NSset. But I am not really sure how to communicate each new object up to the view. Up to this point, I've just been messing around with objects I put on the view and then assign movement to those, this is my first jump into on-the-fly object creation.
It might be that I just need to jump into a class/object type or even a tutorial, any guidance would be great.
Thanks!
Are you asking how to create a 'paint' type application? There's an apple example for that:
http://developer.apple.com/iphone/library/samplecode/GLPaint/Introduction/Intro.html
This question is relevant, but might be too complex when you're just starting out:
Improving Finger Painting Performance
If you're a bit more specific about what problem your app is to solve you might get some more specific answers.