Software Archive
Read-only legacy content
17061 Discussions

Correcting most of the Warnings in Unity3d 5.0.1 after Importing the RSUnityToolkit package

Lance_R_
Beginner
400 Views

Addressing a fix for the basic starting error with the RealSense SDK plugin in Unity 5 has been addressed here:

https://software.intel.com/en-us/forums/topic/542710

Some moderator can merge this thread if they feel the need.  To sum up the basic set up, I'll write the steps quickly, re-iterating in a little more detail how to set up in Unity 5, then additionally help you get rid of some of those warnings about deprecated code as well.  At the time of this post, Unity 5.0.1 is the most recent release version as of April 8th, 2015.

1.  Open Unity 5 (This step is the same for previous versions of Unity; however, Unity 5 will allow you to use the "personal free" version which is the full pro version.  In earlier releases, 4.6 and earlier, you must have the Pro version of Unity).  Anyway, open Unity... and create or select the project in which you want to use the Intel RealSense plugin.  Select "Assets > Import Package > Custom Package" from the menu bar.  You will find the RSUnityToolkit package that you want to import, I'm fairly sure by default, in the "C:\Program Files (x86)\Intel\RSSDK\framework\Unity" folder.  Click this and select all (I'm just saying for general purposes, select all) and click import.

2.  Specifically to get the currently provided RSUnityToolkit package up and running in Unity 5, like Rick Blacker mentioned, you must replace the libxccpp2c.dll and libxccpp2c.dll.signature with the 64 bit versions.  You can find these by default included with the RealSense SDK installation in "C:\Program Files (x86)\Intel\RSSDK\bin\x64" hiding among a lot of other dll files.  Copy these two files and paste them in your Unity 5.0.1 project.  These two files must replace the existing copies located in your project found by default in the "...Assets/Plugins" directory in your hierarchy.

3.  In addition to the two necessary files, you might also note that there is a 64 bit version of the libpxcclr.unity.dll file included in the "C:\Program Files (x86)\Intel\RSSDK\bin\x64" folder.  I would recommend copying this file into your project as well.

 

Now let's get rid of a couple of those pesky warnings that crop up in the console every time Unity re-compiles your code.  

FindObjects.GIF

Let's do the easy one first.  "...warning CS0618: 'UnityEngine.Object.FindSceneObjectsOfType(System.Type) is obsolete."  Clicking on this warning should open up Monodevelop and take you straight to line 90 in the C# script where you can literally do exactly what the warning asks you to do.  Just delete the word "Scene" from the method to use the updated method "FindObjectsOfType" in Unity 5.

LookLikeInspector.GIF

The second one is almost as easy.  "CS0618: 'UnityEditor.EditorGUIUtility.LookLikeInspector()' is obsolete."  There are some Stackoverflow Q&A's covering this.  What you want to do is comment out or delete the offending line of deprecated code, line 80 in Monodevelop according to the warning in my console.  Then add these two lines instead:

EditorGUIUtility.labelWidth = 0; EditorGUIUtility.fieldWidth = 0;

The only warnings you'll have to put up with for the time being (if you imported the entire package) are merely Intel RealSense specific.  They are regarding the use of deprecated methods in the RealSense SDK that may be updated soon.  You can certainly dive in and try to update the methods yourself.  Here's a good starting point:

https://software.intel.com/sites/landingpage/realsense/camera-sdk/2014gold/documentation/html/index.html?pxcblobmodule.html

https://software.intel.com/sites/landingpage/realsense/camera-sdk/2014gold/documentation/html/index.html?pxcblobconfiguration.html

The warning is letting you know that there is a newer, potentially better way to initialize and query the PXCMBlob information from the camera.  Instead of using the PXCMBlobExtractor object, there is an updated way to initialize this object using the PXCMBlobModule class.

If you begin by replacing line 93 in the "SenseToolkitManager.cs" file, you'll see what I mean.  Beyond this point these are no longer instructions.  I'm making some observations and will not attempt to update the blob detection methods.  Replace:

BlobExtractor.GIF

with

PXCMBlobModule.GIF

You could change the name of the object, but that would be more trouble than it's worth.  Ok?  Then do the same thing in line 428 of the "SenseToolkitManager.cs" script.  You'll get some initialization errors because the method for initializing the blob has changed.

BlobModuleErrors.GIF

Initializing the Blob:

https://software.intel.com/sites/landingpage/realsense/camera-sdk/2014gold/documentation/html/manuals_initializing_the_blob_module.html?zoom_highlightsub=pxcmblob

Configuring the Blob:

https://software.intel.com/sites/landingpage/realsense/camera-sdk/2014gold/documentation/html/manuals_configuring_the_blob_module.html?zoom_highlightsub=pxcmblob

The documentation code is very clear and can be followed specifically using the C# sample.  Hopefully if you are interested and have read this far, you can follow this initialization method fairly easily.  Assign the configuration of the BlobExtractor (so it's called in the Unity file) to the "sm" and "blobConfig" objects thus:

BlobModule_Init_and_Config.GIF

 

I guess I could just paste that directly in from Monodevelop... starting from line 615 of "SenseToolkitManager.cs":

                            if (!_isInitBlob)
                            {
                                // the deprecated lines, commented out...
                                //PXCMImage.ImageInfo info = ImageDepthOutput.QueryInfo();
                                //BlobExtractor.Init(info);
                                //BlobExtractor.SetMaxBlobs(MaxBlobsToDetect);
                                //
                                // Create an instance of the SenseManager
                                PXCMSenseManager sm = PXCMSenseManager.CreateInstance();
                                
                                // Enable the blob module
                                sm.EnableBlob();
                                
                                // Get an instance of PXCMBlobModule
                                BlobExtractor = sm.QueryBlob();

                                // Get an instance of PXCMBlobConfiguration
                                PXCMBlobConfiguration blobConfig = BlobExtractor.CreateActiveConfiguration();
                                
                                // Configure the blob module
                                blobConfig.SetMaxBlobs(MaxBlobsToDetect);
                                // … call more configuration methods
                                
                                // Apply the new configuration values
                                blobConfig.ApplyChanges();

                                _isInitBlob = true;
                            }

Anyway, that's where I get stuck updating the blob methods or just don't want to bother right now.  The next piece of the puzzle here would be simply updating the "BlobDetectedRule.cs" file.  Just looking at the function calls, it's clear that a blobConfig method needs to be used instead of directly accessing the BlobExtractor object itself.  If you'd like to dive further down that rabbit hole here, please feel free.

Thanks, and I hope you found the first part helpful at the very least.

Until next time,

0 Kudos
4 Replies
MartyG
Honored Contributor III
400 Views

Great information, Lance, thanks!  I had decided to finish my project in Unity 4.6 because the obsolete errors broke it.  So I look forward to giving this a try sometime with a backup copy of my project (definitely not the original!) and see if it works so I can take advantage of all the extra free features in Unity 5.  ^_^

0 Kudos
Lance_R_
Beginner
400 Views

A project started in an earlier version of Unity, 4.6 or earlier, could require a great deal of additional refactoring in code (much of which Unity tries to auto adjust for you but may not completely update, such as Mechanim animation asset scripts that possibly utilize now unsupported API functions) as well as (but not limited to) re-baking of navmesh prefabs, re-baking baked lighting, small audio re-adjustments...

Documentation on the Unity 5 changes that you may need to consider when upgrading a Unity 4.6 project can be found here on the Unity website:

http://docs.unity3d.com/Manual/UpgradeGuide5.html

The warnings I covered pertain to creating a new Unity 5 project and importing the RSSDK RSUnityToolkit package.

So... good luck upgrading!  If you don't have to upgrade your current project, it could save you a great deal of work.  But if you do need to upgrade a previous project, or just want to upgrade, please read the Upgrade Guide on their website.

^_^

0 Kudos
MartyG
Honored Contributor III
400 Views

Thanks Lance.  Yeah, when I imported it the first time I could see that adapting it to get it working was going to be challenging, to say the least.  It offered the choice to to to fix obsolences during import but that seemed to make the project as broken as leaving them in.  It's a pity, as I've read accounts of how much a project can improve in Unity 5 simply because of the Pro features that are now free.  Still, I do understand that it's the price of progress, just like Intel chose Win 8.1 as RealSense's minimum OS so it wasn't held back by legacy tech.

0 Kudos
MartyG
Honored Contributor III
400 Views

I'd like to add to this excellent article that when I was debugging the last of the bugs caused by importing my project to Unity 5, I kept getting error messages in the console from a number of objects.  The message said:

transform.position assign attempt for <object name> is not valid.  Input position is {NaN, NaN, NaN }.

I looked for a common factor in all of these objects to help diagnose the problem, and found that they were all using a Fixed Joint.  The joint itself was not really the problem though.  What was causing the error was a tick-box labeled 'Enable Preprocessing' at the bottom of the Fixed Joint settings in the Inspector.  It was ticked by default.  Un-ticking this setting in all of the objects with Fixed Joints made the transform.position errors go away.

On a side-note, I also noticed that the texture shader sof every object in the project had been re-labeled as a Legacy Shader after import into Unity 5.  All of the shader types that had been listed in Unity 4.6 and previous were now hidden under a new 'Legacy' sub-menu option at the bottom of Unity 5's shader list.

Whilst the textures will probably work fine if left as they are (hence the term 'Legacy'), it may be the case that changing the shader settings of your imported objects may allow them to take advantage of Unity 5's enhanced graphics capabilities.  New 'Standard' and 'Standard (Specular Setup) options at the top of the shader list may be the new equivalents of the Diffuse and Specular shaders used in the previous versions of Unity.

0 Kudos
Reply