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

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/

Related

TextMesh Pro Area Type Feature like in Illustrator

I was wondering if TextMesh Pro has plans for adding a feature similar to the Area Type feature from Illustrator pictured below, basically having the bounding box of the text object be a custom shape or dependent on something else? There is the option to make your text fit the geometry but that does not seem to be it.
If there are no plans in the near future to make this feature, is there a way for me to look into the specifics of TextMesh Pro and try to make it myself? As far as I've seen I'm able to access some (?) of the source after downloading them from the package manager, but I don't really have an overview of what works with what. My guess would be that I have to look at the parts of the code responsible for creating the yellow bounding box around text objects, but I'm not able to find where that is being done. Alternatively, I'm also looking for how text alignment is being done as my problem does not need an as sophisticated solution as area type objects, just a specific way of formatting the text.

minecraft: How to get coordinates of blocks inside selection

For a Loot Plugin i need all the coordinates of chests in my prebuilt world.
To add them to the plugins config. I am not programming the plugin, i am just using it, i just need a way to get multiple coordinates for specific blocks in a world.
OR
If it is possible to use worldedit and replace chests with chests that have nbt tags i can completely skip the plugin part and use the vanilla loot tables. But i haven't yet found a way to setblocks with nbt data using worldedit.
I was thinking about downloading the map moving it into mcedit or worldpainter and hopefully find a way there to export the coordinates of each chest.
I'm looking forward for some solutions, and i'm thanking you in advance!
If you have to prepare this world initially and only once, I would recomment to use a plugin to identify all the chests in the world (e.g. by iterating through all already generated chunks and all containing blocks), and modifing or saving them, the way you need to. Doing this on a productive server will probably cause lags, cause the iterating/searching will be very intensive.
You could also think about some kind of hacky way, to identify if the blocks are placed by the world generator/a plugin or a player. When u use the plugin LogBlock, you can check, if the clicked chest was placed by a player. If so, treat this chest as a normal chest, otherwise, if no player has ever placed a block at this location, treat the chest as a chest from the "loot plugin".
Any of the ways will work, but the first one will probably be a little harder, since you have to manually load all the chunks. The second is a little bit hacky, but will be more easy, but maybe not compatible to your setup.

Create Custom Unity Inspector Layout

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.

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/

Is there a way to use GflAx to incorporate gradient colours?

Ok, narrow question of the day. I'm using GflAx (from xnview) to create some graphic tiles. I would like to put some gradients in as well though.
Is there a way I can do this within this product?
There is also an SDK which is part of this product but I can't find that info there.
You can not do this but you can create the gradient in another program and then do a "LoadBitmap" make the mods you need ontop of that 'background' and then save to a new file.