Example #1
0
        public static bool LoadHDAFile(HEU_SessionBase session, string assetPath, out HAPI_NodeId assetLibraryID, out string[] assetNames)
        {
            assetLibraryID = HEU_Defines.HEU_INVALID_NODE_ID;
            assetNames     = new string[0];

            // Load the file
            string validAssetPath = HEU_PluginStorage.Instance.ConvertEnvKeyedPathToReal(assetPath);

            if (validAssetPath != null)
            {
                assetPath = validAssetPath;

                HAPI_AssetLibraryId libraryID = 0;
                bool bResult = session.LoadAssetLibraryFromFile(assetPath, false, out libraryID);
                if (!bResult)
                {
                    return(false);
                }

                int assetCount = 0;
                bResult = session.GetAvailableAssetCount(libraryID, out assetCount);
                if (!bResult)
                {
                    return(false);
                }
                Debug.AssertFormat(assetCount > 0, "Houdini Engine: Invalid Asset Count of {0}", assetCount);

                HAPI_StringHandle[] assetNameLengths = new HAPI_StringHandle[assetCount];
                bResult = session.GetAvailableAssets(libraryID, ref assetNameLengths, assetCount);
                if (!bResult)
                {
                    return(false);
                }
                // Sanity check that our array hasn't changed size
                Debug.Assert(assetNameLengths.Length == assetCount, "Houdini Engine: Invalid Asset Names");

                assetNames = new string[assetCount];
                for (int i = 0; i < assetCount; ++i)
                {
                    assetNames[i] = HEU_SessionManager.GetString(assetNameLengths[i]);
                }

                return(true);
            }

            return(false);
        }