Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
hMeshCombiner Class Reference

A drop in implementation of how to interact with the Hydrogen.Threading.Jobs.MeshCombiner. This is meant really as an example of one way of using it, but you will probably want to create your own method to further optimize the workflow. More...

+ Inheritance diagram for hMeshCombiner:

Public Member Functions

void Combine (GameObject rootObject, Transform outputParent, bool disableRootObject)
 Combine all active meshes under the root object. More...
 
void ThreadCallback (int hash, Hydrogen.Threading.Jobs.MeshCombiner.MeshOutput[] meshOutputs)
 This function is called in the example after the MeshCombiner has processed the meshes, it starts a Coroutine to create the actual meshes based on the flat data. This is the most optimal way to do this sadly as we cannot create or touch Unity based meshes outside of the main thread. More...
 

Static Public Member Functions

static bool Exists ()
 Does an Input Manager already exist? More...
 

Public Attributes

Hydrogen.Threading.Jobs.MeshCombiner Combiner = new Hydrogen.Threading.Jobs.MeshCombiner ()
 An instance of the MeshCombiner. More...
 
int ThrottleRate = 180
 This is used in our example to throttle things a bit when accessing Unity objects. More...
 
bool Persistent = true
 Should this input manager survive scene switches? More...
 

Protected Member Functions

void Awake ()
 Unity's Awake Event More...
 

Properties

static hMeshCombiner Instance [get]
 Gets the input manager instance, creating one if none is found. More...
 

Detailed Description

A drop in implementation of how to interact with the Hydrogen.Threading.Jobs.MeshCombiner. This is meant really as an example of one way of using it, but you will probably want to create your own method to further optimize the workflow.

Definition at line 40 of file hMeshCombiner.cs.

Member Function Documentation

void hMeshCombiner.Awake ( )
protected

Unity's Awake Event

Definition at line 193 of file hMeshCombiner.cs.

194  {
195  // Should this gameObject be kept around :) I think so.
196  if (Persistent)
197  DontDestroyOnLoad (gameObject);
198  }
bool Persistent
Should this input manager survive scene switches?
void hMeshCombiner.Combine ( GameObject  rootObject,
Transform  outputParent,
bool  disableRootObject 
)

Combine all active meshes under the root object.

You do not need to wait till completion to call this again with more meshes to combine, however the thread will not call back to Unity till all meshes have been processed in the queue.

Parameters
rootObjectThe "root" GameObject.
outputParentSets the output parent transform.
disableRootObjectIf set to true disable root object (and its children) after iterating through its children..

Definition at line 125 of file hMeshCombiner.cs.

126  {
127  // Do it!
128  StartCoroutine (AddMeshes (rootObject, outputParent));
129 
130  // Disable our example dat
131  if (disableRootObject) {
132  rootObject.SetActive (false);
133  }
134  }
static bool hMeshCombiner.Exists ( )
static

Does an Input Manager already exist?

Definition at line 107 of file hMeshCombiner.cs.

108  {
109  return _staticInstance != null;
110  }
void hMeshCombiner.ThreadCallback ( int  hash,
Hydrogen.Threading.Jobs.MeshCombiner.MeshOutput[]  meshOutputs 
)

This function is called in the example after the MeshCombiner has processed the meshes, it starts a Coroutine to create the actual meshes based on the flat data. This is the most optimal way to do this sadly as we cannot create or touch Unity based meshes outside of the main thread.

Parameters
hashInstance Hash.
meshOutputs.

Definition at line 143 of file hMeshCombiner.cs.

144  {
145  // This is just a dirty way to see if we can squeeze jsut a bit more performance out of Unity when
146  // making all of the meshes for us (instead of it being done in one call, we use a coroutine with a loop.
147  _threadRunning = false;
148  StartCoroutine (CreateMeshes (hash, meshOutputs));
149  }

Member Data Documentation

An instance of the MeshCombiner.

Definition at line 45 of file hMeshCombiner.cs.

bool hMeshCombiner.Persistent = true

Should this input manager survive scene switches?

Definition at line 54 of file hMeshCombiner.cs.

int hMeshCombiner.ThrottleRate = 180

This is used in our example to throttle things a bit when accessing Unity objects.

It seems at 180, its a nice sweet spot for the meshes in our example scene.

Definition at line 50 of file hMeshCombiner.cs.

Property Documentation

hMeshCombiner hMeshCombiner.Instance
staticget

Gets the input manager instance, creating one if none is found.

The Input Manager.

Definition at line 84 of file hMeshCombiner.cs.