public static List<HEU_Handle> FindOrGenerateHandles(HEU_SessionBase session, ref HAPI_AssetInfo assetInfo, HAPI_NodeId assetID, string assetName, HEU_Parameters parameters, List<HEU_Handle> currentHandles) { List<HEU_Handle> newHandles = new List<HEU_Handle>(); if (assetInfo.handleCount == 0) { return newHandles; } HAPI_HandleInfo[] handleInfos = new HAPI_HandleInfo[assetInfo.handleCount]; HEU_GeneralUtility.GetArray1Arg(assetID, session.GetHandleInfo, handleInfos, 0, assetInfo.handleCount); for (int i = 0; i < handleInfos.Length; ++i) { if (handleInfos[i].bindingsCount <= 0) { continue; } string handleName = HEU_SessionManager.GetString(handleInfos[i].nameSH, session); HEU_Handle.HEU_HandleType handleType = HEU_Handle.HEU_HandleType.UNSUPPORTED; string handleTypeString = HEU_SessionManager.GetString(handleInfos[i].typeNameSH, session); if (handleTypeString.Equals(HEU_Defines.HAPI_HANDLE_TRANSFORM)) { handleType = HEU_Handle.HEU_HandleType.XFORM; } else { // Commented out warning as it gets annoying, especially with "Curve" handles //Debug.LogWarningFormat("Asset {0} has unsupported Handle type {0} for handle {1}", assetName, handleName, handleTypeString); continue; } HEU_Handle newHandle = null; foreach (HEU_Handle curHandle in currentHandles) { if (curHandle.HandleName.Equals(handleName)) { newHandle = curHandle; break; } } if (newHandle == null) { newHandle = ScriptableObject.CreateInstance<HEU_Handle>(); } bool bSuccess = newHandle.SetupHandle(session, assetID, i, handleName, handleType, ref handleInfos[i], parameters); if (bSuccess) { newHandles.Add(newHandle); //Debug.LogFormat("Found handle {0} of type {1}", handleName, handleTypeString); } } return newHandles; }
// LOGIC ------------------------------------------------------------------------------------------------------ public List<HEU_Handle> CacheHandles() { List<HEU_Handle> handles = new List<HEU_Handle>(); foreach (Object targetObject in targets) { HEU_Handle handle = targetObject as HEU_Handle; if (handle != null) { handles.Add(handle); } } return handles; }