コード例 #1
0
	public virtual bool DoAssetLoad()
	{
	    string assetPath = _filePath;
	    if (!HEU_Platform.DoesFileExist(assetPath))
	    {
		assetPath = HEU_AssetDatabase.GetValidAssetPath(assetPath);
	    }

	    HAPI_NodeId libraryID = -1;
	    HAPI_NodeId newNodeID = -1;

	    byte[] buffer = null;
	    bool bResult = HEU_Platform.LoadFileIntoMemory(assetPath, out buffer);
	    if (bResult)
	    {
		if (!_session.LoadAssetLibraryFromMemory(buffer, true, out libraryID))
		{
		    HEU_Logger.LogErrorFormat("Unable to load asset library.");
		    return false;
		}
		//HEU_Logger.Log("Loaded asset");

		int assetCount = 0;
		bResult = _session.GetAvailableAssetCount(libraryID, out assetCount);
		if (!bResult)
		{
		    return false;
		}

		int[] assetNameLengths = new int[assetCount];
		bResult = _session.GetAvailableAssets(libraryID, ref assetNameLengths, assetCount);
		if (!bResult)
		{
		    return false;
		}

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

		// Create top level node. Note that CreateNode will cook the node if HAPI was initialized with threaded cook setting on.
		string topNodeName = assetNames[0];
		bResult = _session.CreateNode(-1, topNodeName, "", false, out newNodeID);
		if (!bResult)
		{
		    return false;
		}
		//HEU_Logger.Log("Created asset node");

		_loadData._cookNodeID = newNodeID;
	    }

	    return true;
	}