IMVU / Unity

Current Release here:

Download Version 1.3 (1.0.1.3)

What is this?

This is a unity package that will allow creating Unity projects (games, apps, etc.) that allows interfacing with IMVU. This is an update to a package that was original provided by IMVU and then abandoned. This package currently restores most of that functionality, such as loading an avatar and converting it to Unity’s GameObjects, including textures, animations, and more.

Setup

  1. Download / unzip the zip
    • Zip should have one file.
    • The unzip location doesn’t matter – it’s a temp file that can be deleted after importing files into a Unity project.
  2. Create a new Unity project or open an existing project.
  3. Import the package:
    • Menu -> Assets -> Import Package -> Custom Package
    • Browse to the unitypackage file from step 1
    • You can keep or discard the Demos folder/scenes
    • NOTE: You will need: Resources, Scripts, Shaders, and the DLL

Testing

For an example of how it all works I’d suggest opening the scene under Demos/Outfit/Outfit.

Running unity should show a login screen. After signing in with your IMVU credentials you’ll see a panel of your most recent outfits on the left.


Selecting an outfit will load that 3D avatar and show a list of products to the right.

Required Resource

First, the DLL requires a resource to be present:  LoadingIcon

This resource must be in the root of the Resources folder. Feel free to modify what is displayed by this resource. It should be possible to create an entire prefab with multiple UI elements, though this is untested.

Promises

IMVU created the original IMVU/Unity wrapper and set it up to use Promises – a fairly common pattern for making web calls and handling the result asynchronously. This is mentioned in the IMVU Unity docs but worth mentioning as the DLL continues this practice.

Using the DLL

To use the DLL, you must first call Imvu.Connect, passing in the username/password. The Connect() call returns a promise with a UserModel. It’s best to see how this works in a demo project.

For example, see the Connect demo. Opening the ConnectionController you’ll see an OnSubmit with the following code:

    Imvu.Connect(args.Username, args.Password).Then(
        userModel => {
            avatar = new GameObject();
            return avatar.AddComponent().Load(userModel);
        }
    ).MatchErr(
        error => {
            ShowError(error);
    });

Of note – the “.Then(…)” is a function that is passed a UserModel. The UserModel contains a few key methods used by some demos. There is also a component called LocalAssetLoader that can load various models – including the UserModel (as shown above).

The “ShowError” method used by the error handling is part of the LoginUI. See LoginUI for more information.

LoginUI

The demos include a prefab called LoginUI. This is a modification of a prefab originally provided by IMVU. It mostly consists of a UI to accept the username/password and buttons for submit and cancel.

The LoginUI is not required to use the DLL or IMVU and Unity. It is just a mechanism for the demos to gather the credentials and display errors during the Imvu.Connect() call.

In a custom Unity app, you can handle credentials any way you like. When ready to connect, call Imvu.Connect(username, password) and handle the success/failure through the standard Promise’s mechanisms.

Posting to Feed

The demos include FeedPost, which will display your current outfit and a “Screenshot” button. When pressed, a dialog displays the screenshot that will be posted and the option to add a message.

Unfortunately, at the current time there is a bit of “coupling” between the DLL and the demo. Specifically, the DLL will try and create a prefab named “FeedUI” which is included in the unity package. If you want to use the post-to-feed logic, you’ll have to provide a prefab named FeedUI.

In addition, the FeedUI must have a script component using FeedPostUI, which needs a reference to the image that will be uploaded and a text field containing the text to go with the post. You should be able to make any prefab you like as long as the FeedPostUI script is attached and as long as the prefab is named FeedUI. If any part of that doesn’t work, please let Dan know.



Older Versions:

Version 1.1 (1.0.1.1)
Version 1.2 (1.0.1.2)