public void Start() { //Debug.Log( "HoudiniApiAssetAccessorExample: Start" ); parmIndex = 0; parmNames = null; myAsset = null; parmName = ""; parmSize = 0; parmType = HoudiniApiAssetAccessor.ParmType.INVALID; parmIntValue = null; parmFloatValue = null; parmStringValue = null; // If the game object has a HAPI_Asset component then get // the parameters for this asset and set the selected // parameter to be the asset's first parameter myAsset = HoudiniApiAssetAccessor.getAssetAccessor(gameObject); if (myAsset != null) { Debug.Log("Asset name: " + myAsset.prName); parmNames = myAsset.getParameters(); setSelectedParameter(); } }
// Set the currently selected parameter and retrieve its values public void setSelectedParameter() { try { if (!hasAsset()) { return; } parmName = parmNames[parmIndex]; parmSize = myAsset.getParmSize(parmName); parmType = myAsset.getParmType(parmName); parmIntValue = null; parmFloatValue = null; parmStringValue = null; if (parmType == HoudiniApiAssetAccessor.ParmType.INT) { parmIntValue = new int[parmSize]; for (int i = 0; i < parmSize; i++) { parmIntValue[i] = myAsset.getParmIntValue(parmName, i); } } else if (parmType == HoudiniApiAssetAccessor.ParmType.FLOAT) { parmFloatValue = new float[parmSize]; for (int i = 0; i < parmSize; i++) { parmFloatValue[i] = myAsset.getParmFloatValue(parmName, i); } } else if (parmType == HoudiniApiAssetAccessor.ParmType.STRING) { parmStringValue = new string[parmSize]; for (int i = 0; i < parmSize; i++) { parmStringValue[i] = myAsset.getParmStringValue(parmName, i); } } } catch (HoudiniError err) { Debug.LogError(err.ToString()); } }