Jump to content
Sign in to follow this  
Matt1988

ProGrids API

Recommended Posts

This is being carried over from http://www.sixbysevenstudio.com/forum/viewtopic.php?f=10&t=141

felt it was time to make a separate post about this for posterity.

As it turns out, I sat down and thought really hard about exactly what I need out of a ruler extension in Unity3d so I scrapped what I had and am starting from the ground up.

I am using Handles.PositionHandle in my extension and getting them to snap to ProGrids snap points is easy and straightforward but what I am having problems with is after I use the ProGrids class in my project, without ProGrids installed my extension throws a type or namespace error. I've tried to look up methods to get around this on google, I know there has to be one but I don't know what too look for.

If anyone has a solution to this problem I'd greatly appreciate a share or just point me in the right direction

Thanks!

Share this post


Link to post
Share on other sites

Ah, this issue! I ran into the same problem when integrating ProGrids and ProBuilder. Since it is not guaranteed that they will be installed in parallel, they had to both work together and separately.

If you look in the ProGrids source code, there's a method called `UpdateProBuilder`, or something close to that. That function uses Reflection to look for the pb_Object class, and if present, send it instructions. I ended up just placing all the ProBuilder specific snapping code inside ProBuilder, so that way the bridge method only needed to update ProBuilder with snap and enabled values.

Share this post


Link to post
Share on other sites

Very sneaky Karl :D

I think that I may have found a solution that would allow any user to tie into progrids the way that probuilder does using delegates.

set up an event that ProGrids would call every time it changed, sending out the snap setting. then set up a method (in progrids) that would add a passed method parameter to the events delegate.

To tie into it you would then use Unity from the script that you are trying to access to determine if ProGrids exists and if it does use reflection to invoke the method described above and pass the method that you wish to add to the delegate as a parameter.

I'm not 100% sure if this technique would work or not, I haven't been able to test it. I haven't been able to test it because it appears that JS doesn't support delegates :o

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×