Git Visual Explanations: Merge, Reset, Rebase and Squash

These are some visual git operations explanations I found. Enjoy

Git Reset:

Simple Rebase:

Merge vs Rebase:

Merge vs Squash:

Rebase from origin/master:

Pull and Rebase from origin/master:

Rebase and Pull ending with 2 branches:

Rebase onto:

Rebase onto and onto again:

Did you like this? Share it:

Unity3D Tutorials: Custom Editor, Inspector, Property Drawers and Editor Windows

Note: This post will be regularly updated with other examples. Make sure to return later. Last edit: 31/Jan/2015

There are a few official tutorials [1][2] and videos about this subject, and others made by community. The thing is, the manual itself doesn’t cover a lot of things, it uses mostly UnityScript, and many other things lacks of examples. In this post, I’ll try to keep it always updated with my last codes.

First, lets start with the basics, and I assume you know Unity3D and C# well. The default Unity inspector have a few properties bars built-in, and sometimes it’s not enough. The not-so-new Unity 4 introduced Property Drawers. If you have an unique property in diferent objects, then that’s what you need. Let’s take a look on how default built-in properties works.

My Enemy class:

That gives me the following inspector:
Custom Inspector - Default

Now let’s add a “power attack” to our enemy. It will be a simple Serializable Class. Check the following code:

Before talking about Property Drawers, you must know that you can create a custom PropertyAttribute, just like Attributes in C#. Range and Multiline are built-in, but you can create your own, and combine with Property Drawers. As far as I can tell, PropertyAttribute’s can only deal with one property. Property Drawers can combine PropertyAttribute, and/or other properties for a better display.

So, I added a struck and an enum type. The special attack its level-type property. Lets say the enemy will attack with Melee until level 20, Range between 21 and 30, and Magic from level 31. So, let’s create our SpecialAttack Custom Property Drawer

SpecialDrawer.cs:

Explaining: I store the original Rect position given by my PropertyDrawer, and I do some modifications with the axis X and width. This way, I can display the 2 properties in one line. The EditorGUI.PropertyField can guess what type of variable it is, thats why it renders Popups with Enum, TextField’s for strings, and so on. You can force it to draw an IntSlider instead of a simple textfield. We will talk about this in another topic.

Level/Type Property

Ok, what about forcing Type according to Level value? I’m just doing that to demonstrate how we can manipulate values inside a Property Drawer. If it was real case, I would probably use some Label to display the Type, because changing it would have no value because its linked to level value. Anyway, here’s an updated code:

Also I am forcing the Level values between 1 and 50. I could also do that using [Range(1,50)] inside SpecialAttack class, like this:

Then I am forcing the Type value using simple if checks. Hope it helps… use the comment section!

Did you like this? Share it:

Unobtrusive Confirm Javascript Replacement with jquery UI Dialog

Today I needed to implement an unobstrusive replacement for native alert and confirm functions for a client’s project. I searched a lot of libs and solutions but none of them worked as I wanted. So I decided to at least try to implement one real unosbtrusive replacement.

Here we go. First we need jQuery, jQuery UI Core (core, widget, position) and widget (dialog), choose any theme and we are set.

Take a look at the code below:

After that i need to overload the native confirm function. Check the next code:

Note that this function you can customize whatever you want, but here I’m using jQuery UI Dialog. You can try your own if you want, just pay attention on line 13, when I throw the callback. Of course, this is the first draft of workaround, maybe someone can increment the idea.

Heres the full code:

Did you like this? Share it: