Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Overview

The vhAssetsPackage is a redistributable Unity3D Engine package file that contains functionality for allowing Smartbody and VHMsg to work from within the Unity3D engine.

The Toolkit uses Unity as it's primary rendering engine.  It can run in Unity Free or Unity Pro.  For Unity Free, we interface with Smartbody using 'bonebus mode'.  For Unity Pro, we access Smartbody directly using a .dll.

Some additional functionality that the vhAssetsPackage contains is:

  • An extension of MonoBehaviour that allows order-dependent initialization and updates
  • Smartbody interface
  • VHMsg interface
  • VHCL Audio interface
  • Asset Post-processors that ease pipeline integration
  • Resolution independent UI classes
  • Interactive Debug Panel
  • Customizable Free Mouse Look
  • Ini file configuration
  • Loading Screen
  • Performance time demo tests
  • File Parsing
  • Application setup point
  • Customizable build process
  • Fps and Memory Debug Info

Any of these optional components are available when installing the vhAssetsPackage

Quick facts:

Unity

Unity is available within ICT.  The latest version is available through SVN here:

https://svn.ict.usc.edu/svn_vh/trunk/core/Unity

This location has the latest up-to-date version of Unity, with the documentation pruned for space.

The entire Unity distribution is available here.  

https://svn.ict.usc.edu/svn_vh/vendor/unity/current

Also, all previous versions of Unity are tagged in this vendor branch as well.

Please note that you need a Serial # for Unity Pro.  Please contact Helpdesk for a Serial #.

For projects, it is recommended to use the version of Unity in SVN.  It is virtually the same as installing Unity from the web site*.  But you get the bonus of:

  • Knowing that every person on the project is using the exact same version of Unity.
  • Upgrading to a newer version is as easy as updating the svn external.  No need to uninstall, distribute the installer, etc.
  • Allows different projects to use different versions of Unity, depending on their timetables.  Very useful when working on multiple projects on the same machine.

* The only difference in installing Unity vs using SVN is that certain file associations are not registered (in Windows).  So, double-clicking on a .unitypackage will not open it.  But right-click->Import New Package works fine.

More internal Unity documentation can be found here:  Unity

Using vhAssets

Location

vhAssets is distributed via the vhAssetsPackage.unitypackage.  It is built regularly by our build server, so it will always contain the latest code.  It can be found, along with all of our other Unity packages here:

\\vhbuild2\VHToolkit-Builds (sort by Date)

The source for this package is stored here at https://svn.ict.usc.edu/svn_vh/trunk/lib/vhunity

First Time Installation

  1. Bring the .unityPackage file inside of your Unity project Assets folder
  2. Double click it
  3. Click Import
  4. Add all the imported files into svn

Upgrading

Upgrading .unitypackage files is a little more difficult.  This quote from the Unity docs explains it:

"For the cleanest possible upgrade, it should be considered to remove the old package contents first, as some scripts, effects or prefabs might have become deprecated or unneeded and Unity packages don't have a way of deleting (unneeded) files (but make sure to have a security copy of the old version available)."

The easiest way I've found is to use the approach the SVN docs recommend for vendor branch upgrades.

  1. remove all files from the folders you are upgrading (leaving the .svn folders)
  2. install the .unitypackage as normal
  3. bring up the SVN Commit dialog.  Then SVN Add all 'non-versioned' files, and SVN Delete all 'missing' files.

Users

Through the Unity Editor, many variables of vhAssets script components can be customized

DebugConsole

Captures all Smartbody and Unity log ouput and display it to user. Also can be used to send commands. Type '?' for a list of available commands.

Variable NamePurposeValue Range
Percentage Of ScreenThe amount of vertical space that the debug console GUI will spanfloat 0 - 1

FreeMouseLook

Variable NamePurposeValue Range
AxesSpecifies which axes the camera can rotate aroundMouseX, MouseY, MouseXAndY
Sensitivity X/YAngular velocity for camera rotationfloat
Movement SpeedLinear velocity for camera movementfloat
Secondary MovementLinear velocity for camera movement when holding the left shift keyfloat
Maximum X//YMax angle the camera can rotate on an axis before being clamped-360 to +360
Minimum X/YMin angle the camera can rotate on an axis before being clamped-360 to +360
Camera Rotation OnEnables/Disables camera rotation from mouse movement: True or FalseTrue/False
Move Keys

Allows specification for which keys are used to make the camera move

up, down, left, right, forward, backward, and toggle rotation on/off

KeyCode

Loading Screen

Provides functionality for full screen image

VHBehaviour

Allows for control of the call ordering of all MonoBehaviour messages sent from Unity.

Variable NamePurposeValue Range
Initial Priority

The ordering in which this script will be called compared to other VHBehaviours.

 A lower number entails a higher priority. i.e. priority 0 behaviours get processed

before priority 10 behaviours

int

VHBehaviourManager

The control system that allows for correct processing order of VHBehaviours.  This object MUST be present in order for VHBehaviours to work

VHWayPointNavigator

Variable NamePurposeValue Range
SpeedLinear movement rate at which you move between waypointsfloat
Turn Towards TargetTurn to face your next waypoint target.True/False
Ignore HeightOnly move to next waypoint along the x/z axesTrue/False
Immediately Start PathingStart Pathing: As soon as the scene starts, start movingTrue/False
Loop TypeAction to take upon reaching the last way point of the pathLoop, Ping Pong, Stop
PatherThe gameobject that will do the movingGameObject
WayPointsThe list of transforms that will be used as waypoints for the pather to move alongGameObject

VHTimeDemo

Works with VHWayPointNavigator and FpsCounter to track performance along a specified path in the scene and then uploads fps/performance data to a database

Variable NamePurposeValue Range
Time Demo NameIdentifying name of this time demo. Used for starting a specific time demo through the console or command linestring
Performance Log NameThe filename for the output log from unity's performance trackingstring
Project NameSpecifies the project this demo is used forstring
Time Demo LengthThe amount of time it will take for the time demo to complete once startedpositive float
Fps Sampling RateHow often the fps will be sampled during the time demopositive float

SmartbodyManager

Interfaces with smartbody.dll to provide smartbody character animation to unity

Variable NamePurposeValue Range
Path To SBM FilesThe directory in which smartbody should look for initialization files. Starting directory is the current unity project folderstring
Character Load PathProject subdirectory in which character prefabs should be instantiated fromstring
Position Scale

Units of measurement between smartbody and unity can sometimes be different based on how the art was exported.

If there is a difference, it can be mitigated with this variable

positive float
Display Log MessagesToggle for allowing smartbody LOGs to be output to unity.True/False
All Facebone CharactersToggle for making all unity smartbody driven characters facebone drive or notTrue/False
Cam SettingsUsed for the SBMonitor to duplicate the renderer viewport and camerapositive float
Initial VHMsgs to SendVHMsgs that will get sent as soon as smartbody is initializedstring

UnitySmartbodyCharacter

Works with SmartbodyManager to have a smartbody driven character inside of unity

Variable NamePurposeValue Range
Bone Parent NameChild gameobject name path that will lead to the skeleton rootstring
Is Face Bone Driven:Toggle that informs smartbody whether or not this character is face bone drivenTrue/False

VHMsgManager

Interfaces with VHMsg that allows communication via strings between processes

Variable NamePurposeValue Range
Use Specified Host and PortIf checked, the Host and Port specified will be used on connection, otherwise localhost and 61611 will be usedTrue/False
HostHost to connect tostring
PortPort to connect topositive int

Developers

All vhAssets code can be modified directly in the repository https://svn.ict.usc.edu/svn_vh/trunk/lib/vhunity/vhAssets

Here are some examples for common functionality that is modified on a per project basis

DebugConsole

Add a new command callback for an arbitrary command

m_Console.AddCommandCallback("some_command", new DebugConsole.ConsoleCallback(HandleConsoleMessage));

void HandleConsoleMessage(string commandEntered, DebugConsole console) {

      if (commandEntered.IndexOf("some_command") != -1)

           // Do Something

}

To use the console, at run-time hit the ~ key. Type '?' and hit enter to see a list of commands. If you used the code above in your script, you should see "some_command" in the list. Note, you can pass additional arguments with these commands.

Send arguments with a command while typing in the console

vhmsg someMessage

VHMsgManager

Subscribe to a certain type of message

vhmsg.SubscribeMessage("someMessage");

Subscribe to all vhmsgs

vhmsg.SubscribeMessage("*");

Send a vhmsg

vhmsg.SendVHMsg("someMessage someParam1");

Handle a message

vhmsg.AddMessageEventHandler(new VHMsgBase.MessageEventHandler(VHMsg_MessageEvent));

void VHMsg_MessageEvent(object sender, VHMsgBase.Message message) {

     string [] splitargs = message.s.Split( " ".ToCharArray() );

     if (splitargs[0] == "someMessage")

          // Do Something

}

Build Process

You can customize the build process by creating and modifying a BuildSettings.xml file.

  1. Inside the assets folder in your unity project, create a file called BuildSettings.xml
  2. In the same folder as the Assets folder within your Unity project create a .bat file with the following lines

    @setlocal

    set PROJECTPATH=%CD%

    pushd ..\Unity

    call runEditorBatch.bat -projectPath %PROJECTPATH% -batchmode -nographics -quit -executeMethod UnityStartup.PerformWindowsBuild

    popd

    @endlocal

  3. Use the following template for custom modification

    <?xml version="1.0" encoding="utf-8"?>
    <BuildSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cpandl.com">
      <ExternalAssetsPaths>
        <string>Assets/SomeDirectory</string>
        <string>Assets/SomeOtherDirectory</string>
      </ExternalAssetsPaths>
      <BuildOutputPath>Builds/YourProject/YourProject.exe</BuildOutputPath>
      <PostBuildScript>somePostBuildScript.bat</PostBuildScript>
      <ConfigFiles>
        <string>Assets/config.ini</string>
      </ConfigFiles>
    </BuildSettings>

BuildSettings.xml Format

FieldDesrcription
ExternalAssetsPathsArray of folder names that will be copied to the BuildOutputPath. (OPTIONAL)
BuildOutputPath

Path specifying the name and location of the .exe for your build (REQUIRED)

PostBuildScript

A .bat or .exe that will be run after the build process is completed. (OPTIONAL)

ConfigFilesArray of file names taht will be copied to the BuildOutputPath. (OPTIONAL)

 

Config File Parsing

You can create a config .ini file in your project and read it using the IniParser class

m_ConfigFile = new IniParser(configFileName);

m_ConfigFile.GetSetting("SomeSetting") // returns a string with the value of that setting, if it exists

Known Issues

Either list of common known issues and/or link to all Jira tickets with that component name.

FAQ

FAQ

 

 

 

  • No labels