/// <summary> /// Query the parameters in the HDA, and change some values. /// </summary> /// <param name="houdiniAsset">The HEU_HoudiniAsset of the loaded asset</param> public static void ChangeParmsAndCook(HEU_HoudiniAsset houdiniAsset) { // Always get the latest parms after each cook List <HEU_ParameterData> parms = houdiniAsset.Parameters.GetParameters(); if (parms == null || parms.Count == 0) { Debug.LogFormat("No parms found"); return; } // -------------------------------------------------------------------- // Example to loop over each parm, checking its type and name. Then setting value. StringBuilder sb = new StringBuilder(); foreach (HEU_ParameterData parmData in parms) { sb.AppendLine(string.Format("Parm: name={0}, type={1}", parmData._labelName, parmData._parmInfo.type)); if (parmData._parmInfo.type == HAPI_ParmType.HAPI_PARMTYPE_BUTTON) { // Display a button: parmData._intValues[0]; } else if (parmData._parmInfo.type == HAPI_ParmType.HAPI_PARMTYPE_FLOAT) { // Display a float: parmData._floatValues[0]; // You can set a float this way HEU_ParameterUtility.SetFloat(houdiniAsset, parmData._name, 1f); // Or this way (the index is 0, unless its for array of floats) parmData._floatValues[0] = 1; } } Debug.Log("Parameters: \n" + sb.ToString()); // -------------------------------------------------------------------- // Examples to look up a parm via name, and set it. // Use helper to set float parameter with name HEU_ParameterUtility.SetFloat(houdiniAsset, "gravity", 5f); // Use helper to set random color HEU_ParameterUtility.SetColor(houdiniAsset, "branch_vtx_color_color", Random.ColorHSV()); // Make sure to cook after changing parms CookAsset(houdiniAsset); }
private void UpdateGravity() { if (_evergreenAsset != null) { float g = (1.0f + Mathf.Sin(Time.realtimeSinceStartup)) * _scale; // Use helper to set float parameter with name HEU_ParameterUtility.SetFloat(_evergreenAsset, "gravity", g); // Use helper to set random color HEU_ParameterUtility.SetColor(_evergreenAsset, "branch_vtx_color_color", Random.ColorHSV()); // Cook synchronously to guarantee geometry generated in this update. _evergreenAsset.RequestCook(true, false, true, true); } }