Пример #1
0
        /// <summary>
        /// Cook the PDG graph of the specified TOP network
        /// </summary>
        /// <param name="topNetwork"></param>
        public void CookTOPNetworkOutputNode(HEU_TOPNetworkData topNetwork)
        {
#if HOUDINIENGINEUNITY_ENABLED
            HEU_SessionBase session = GetHAPIPDGSession();
            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            // Cancel all cooks. This is required as otherwise the graph gets into an infinite cook
            // state (bug?)
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    session.CancelPDGCook(contextID);
                }
            }

            if (!session.CookPDG(topNetwork._nodeID, 0, 0))
            {
                Debug.LogErrorFormat("Cook node failed!");
            }
#endif
        }
        /// <summary>
        /// Cook the PDG graph of the specified TOP network
        /// </summary>
        /// <param name="topNetwork"></param>
        public void CookTOPNetworkOutputNode(HEU_TOPNetworkData topNetwork, System.Action <HEU_PDGCookedEventData> OnCook = null)
        {
#if HOUDINIENGINEUNITY_ENABLED
            ClearEventMessages();

            HEU_SessionBase session = GetHAPIPDGSession();
            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            // Cancel all cooks. This is required as otherwise the graph gets into an infinite cook
            // state (bug?)
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    session.CancelPDGCook(contextID);
                }
            }

            if (!session.CookPDG(topNetwork._nodeID, 0, 0))
            {
                HEU_Logger.LogErrorFormat("Cook node failed!");
            }

            _cookedDataEvent = OnCook;

            ResetCallbackVariables();
#endif
        }
Пример #3
0
	private static void ClearTOPNetworkWorkItemResults(HEU_TOPNetworkData topNetwork)
	{
	    foreach (HEU_TOPNodeData node in topNetwork._topNodes)
	    {
		ClearTOPNodeWorkItemResults(node);
	    }
	}
Пример #4
0
	/// <summary>
	/// Set the TOP node at the given index in the given TOP network as currently selected TOP node
	/// </summary>
	/// <param name="network">Container TOP network</param>
	/// <param name="newIndex">Index of the TOP node to be selected</param>
	public void SelectTOPNode(HEU_TOPNetworkData network, int newIndex)
	{
	    if (newIndex < 0 || newIndex >= network._topNodes.Count)
	    {
		return;
	    }

	    network._selectedTOPIndex = newIndex;
	}
        private void SetupTopNetworkNames(HEU_TOPNetworkData topNetwork)
        {
	    // Get list of updated TOP node names
	    List<KeyValuePair<int, HEU_TOPNodeData>> displayNodeNames = GetNonHiddenTOPNodes(topNetwork);
	    topNetwork._topNodeNames = new string[displayNodeNames.Count];
	    for (int i = 0; i < displayNodeNames.Count; ++i)
	    {
		topNetwork._topNodeNames[i] = displayNodeNames[i].Value._nodeName;
	    }
        }
Пример #6
0
	public void ResetTOPNetworkWorkItemTally(HEU_TOPNetworkData topNetwork)
	{
	    if (topNetwork != null)
	    {
		int numNodes = topNetwork._topNodes.Count;
		for (int i = 0; i < numNodes; ++i)
		{
		    topNetwork._topNodes[i]._workItemTally.ZeroAll();
		}
	    }
	}
Пример #7
0
	/// <summary>
	/// Dirty the currently selected TOP network and clear all work item results.
	/// </summary>
	public void DirtyAll()
	{
	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null && pdgSession.DirtyAll(topNetwork._nodeID))
		{
		    ClearTOPNetworkWorkItemResults(topNetwork);
		}
	    }
	}
Пример #8
0
	public HEU_TOPNodeData GetSelectedTOPNode()
	{
	    HEU_TOPNetworkData topNetwork = GetTOPNetwork(_selectedTOPNetwork);
	    if (topNetwork != null)
	    {
		if (topNetwork._selectedTOPIndex >= 0 && topNetwork._selectedTOPIndex < topNetwork._topNodes.Count)
		{
		    return topNetwork._topNodes[topNetwork._selectedTOPIndex];
		}
	    }
	    return null;
	}
	public List<KeyValuePair<int, HEU_TOPNodeData>> GetNonHiddenTOPNodes(HEU_TOPNetworkData topNetwork)
	{
	    List<KeyValuePair<int, HEU_TOPNodeData>> nonHiddenNodes = new List<KeyValuePair<int, HEU_TOPNodeData>>();

	    for (int i = 0; i < topNetwork._topNodes.Count; ++i)
	    {
		if (topNetwork._topNodes[i]._tags._show)
		{
		    nonHiddenNodes.Add(new KeyValuePair<int, HEU_TOPNodeData>(i, topNetwork._topNodes[i]));
		}
	    }

	    return nonHiddenNodes;
	}
Пример #10
0
        public void CancelCook(HEU_TOPNetworkData topNetwork)
        {
            HEU_SessionBase session = GetHAPIPDGSession();

            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            // Cancel all cooks.
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    session.CancelPDGCook(contextID);
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Pause the PDG graph cook of the specified TOP network
        /// </summary>
        /// <param name="topNetwork"></param>
        public void PauseCook(HEU_TOPNetworkData topNetwork)
        {
#if HOUDINIENGINEUNITY_ENABLED
            HEU_SessionBase session = GetHAPIPDGSession();
            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            // Cancel all cooks.
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    session.PausePDGCook(contextID);
                }
            }
#endif
        }
		public void DirtyAll()
		{
			HEU_SessionBase session = GetHAPISession();
			if (session == null || !session.IsSessionValid())
			{
				return;
			}

			HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
			if (topNetwork != null)
			{
				if (!session.DirtyPDGNode(topNetwork._nodeID, true))
				{
					Debug.LogErrorFormat("Dirty node failed!");
					return;
				}

				ClearTOPNetworkWorkItemResults(topNetwork);
			}
		}
Пример #13
0
	/// <summary>
	/// Cancel the PDG cook of the currently selected TOP network
	/// </summary>
	public void CancelCook()
	{
	    HEU_SessionBase session = GetHAPISession();
	    if (session == null || !session.IsSessionValid())
	    {
		return;
	    }

	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		//Debug.Log("Cooking output!");

		_workItemTally.ZeroAll();
		ResetTOPNetworkWorkItemTally(topNetwork);

		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null)
		{
		    pdgSession.CancelCook(topNetwork);
		}
	    }
	}
	/// <summary>
	/// Cook the output TOP node of the currently selected TOP network.
	/// </summary>
	public void CookOutput()
	{
	    HEU_SessionBase session = GetHAPISession();
	    if (session == null || !session.IsSessionValid())
	    {
		return;
	    }

	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		//HEU_Logger.Log("Cooking output!");

		_workItemTally.ZeroAll();
		ResetTOPNetworkWorkItemTally(topNetwork);

		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null)
		{
		    pdgSession.CookTOPNetworkOutputNode(topNetwork, OnSyncComplete);
		}
	    }
	}
	/// <summary>
	/// Find all TOP networks from linked HDA, as well as the TOP nodes within, and populate internal state.
	/// </summary>
	/// <returns>True if successfully populated data</returns>
	public bool PopulateTOPNetworks()
	{
	    HEU_SessionBase session = GetHAPISession();

	    HAPI_NodeId[] allNetworkNodeIds = HEU_PDGSession.GetNonBypassedNetworkIds(session, _assetID);
	    if (allNetworkNodeIds == null || allNetworkNodeIds.Length == 0)
	    {
		return false;
	    }

	    // Holds TOP networks in use
	    List<HEU_TOPNetworkData> newNetworks = new List<HEU_TOPNetworkData>();

	    // Find nodes with TOP child nodes
	    foreach (HAPI_NodeId currentNodeId in allNetworkNodeIds)
	    {
		HAPI_NodeInfo topNodeInfo = new HAPI_NodeInfo();
		if (!session.GetNodeInfo(currentNodeId, ref topNodeInfo))
		{
		    return false;
		}

		string nodeName = HEU_SessionManager.GetString(topNodeInfo.nameSH, session);
		//HEU_Logger.LogFormat("Top node: {0} - {1}", nodeName, topNodeInfo.type);

		// Skip any non TOP or SOP networks
		if (topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_TOP && topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_SOP)
		{
		    continue;
		}

		// Get list of all TOP nodes within this network.
		HAPI_NodeId[] topNodeIDs = null;
		if (!HEU_SessionManager.GetComposedChildNodeList(session, currentNodeId, (int)(HAPI_NodeType.HAPI_NODETYPE_TOP), (int)HAPI_NodeFlags.HAPI_NODEFLAGS_TOP_NONSCHEDULER, true, out topNodeIDs))
		{
		    continue;
		}

		// Skip networks without TOP nodes
		if (topNodeIDs == null || topNodeIDs.Length == 0)
		{
		    continue;
		}

		// Get any filter tags from spare parms on TOP nodes
		TOPNodeTags tags = new TOPNodeTags();
		if (_useHEngineData)
		{
		    ParseHEngineData(session, currentNodeId, ref topNodeInfo, ref tags);

		    if (!tags._showHEngineData)
		    {
			continue;
		    }
		}
		else
		{
		    tags._show = true;
		    tags._showHEngineData = true;
		}

		HEU_TOPNetworkData topNetworkData = GetTOPNetworkByName(nodeName, _topNetworks);
		if (topNetworkData == null)
		{
		    topNetworkData = new HEU_TOPNetworkData();
		}
		else
		{
		    // Found previous TOP network, so remove it from old list. This makes
		    // sure to not remove it when cleaning up old nodes.
		    _topNetworks.Remove(topNetworkData);
		}

		newNetworks.Add(topNetworkData);

		topNetworkData._nodeID = currentNodeId;
		topNetworkData._nodeName = nodeName;
		topNetworkData._parentName = _assetName;
		topNetworkData._tags = tags;

		if (PopulateTOPNodes(session, topNetworkData, topNodeIDs, _useHEngineData))
		{
		    for (int i = 0; i < topNetworkData._topNodes.Count; i++)
		    {
			if (topNetworkData._topNodes[i]._tags._show)
			{
			    topNetworkData._selectedTOPIndex = i;
			    break;
			}
		    }
		}
	    }

	    // Clear old TOP networks and nodes
	    ClearAllTOPData();
	    _topNetworks = newNetworks;

	    // Update latest TOP network names
	    _topNetworkNames = new string[_topNetworks.Count];
	    for (int i = 0; i < _topNetworks.Count; ++i)
	    {
		_topNetworkNames[i] = _topNetworks[i]._nodeName;
	    }

	    return true;
	}
Пример #16
0
	/// <summary>
	/// Given TOP nodes from a TOP network, populate internal state from each TOP node.
	/// </summary>
	/// <param name="session">Houdini Engine session</param>
	/// <param name="topNetwork">TOP network to query TOP nodes from</param>
	/// <param name="topNodeIDs">List of TOP nodes in the TOP network</param>
	/// <param name="useHEngineData">Whether or not to use HEngine data for filtering</param>
	/// <returns>True if successfully populated data</returns>
	public static bool PopulateTOPNodes(HEU_SessionBase session, HEU_TOPNetworkData topNetwork, HAPI_NodeId[] topNodeIDs, bool useHEngineData)
	{
	    // Holds list of found TOP nodes
	    List<HEU_TOPNodeData> newNodes = new List<HEU_TOPNodeData>();

	    foreach (HAPI_NodeId topNodeID in topNodeIDs)
	    {
		// Not necessary. Blocks main thread.
		//session.CookNode(childNodeID, HEU_PluginSettings.CookTemplatedGeos);

		HAPI_NodeInfo childNodeInfo = new HAPI_NodeInfo();
		if (!session.GetNodeInfo(topNodeID, ref childNodeInfo))
		{
		    return false;
		}

		string nodeName = HEU_SessionManager.GetString(childNodeInfo.nameSH, session);
		//Debug.LogFormat("TOP Node: name={0}, type={1}", nodeName, childNodeInfo.type);

		TOPNodeTags tags = new TOPNodeTags();
		if (useHEngineData)
		{
		    ParseHEngineData(session, topNodeID, ref childNodeInfo, ref tags);

		    if (!tags._show)
		    {
			continue;
		    }
		}
		else
		{
		    tags._show = true;
		}

		HEU_TOPNodeData topNodeData = GetTOPNodeByName(nodeName, topNetwork._topNodes);
		if (topNodeData == null)
		{
		    topNodeData = new HEU_TOPNodeData();
		}
		else
		{
		    topNetwork._topNodes.Remove(topNodeData);
		}

		newNodes.Add(topNodeData);

		//topNodeData.Reset();
		topNodeData._nodeID = topNodeID;
		topNodeData._nodeName = nodeName;
		topNodeData._parentName = topNetwork._parentName + "_" + topNetwork._nodeName;
		topNodeData._tags = tags;
	    }

	    // Clear old unused TOP nodes
	    for (int i = 0; i < topNetwork._topNodes.Count; ++i)
	    {
		ClearTOPNodeWorkItemResults(topNetwork._topNodes[i]);
	    }
	    topNetwork._topNodes = newNodes;

	    // Get list of updated TOP node names
	    topNetwork._topNodeNames = new string[topNetwork._topNodes.Count];
	    for (int i = 0; i < topNetwork._topNodes.Count; ++i)
	    {
		topNetwork._topNodeNames[i] = topNetwork._topNodes[i]._nodeName;
	    }

	    return true;
	}
Пример #17
0
	/// <summary>
	/// Find all TOP networks from linked HDA, as well as the TOP nodes within, and populate internal state.
	/// </summary>
	/// <returns>True if successfully populated data</returns>
	public bool PopulateTOPNetworks()
	{
	    HEU_SessionBase session = GetHAPISession();

	    HAPI_NodeInfo assetInfo = new HAPI_NodeInfo();
	    if (!session.GetNodeInfo(_assetID, ref assetInfo, true))
	    {
		return false;
	    }

	    // Get all networks within the asset, recursively.
	    // The reason to get all networks is because there can be TOP network SOP which isn't a TOP network type, but rather a SOP type
	    int nodeCount = 0;
	    if (!session.ComposeChildNodeList(_assetID, (int)(HAPI_NodeType.HAPI_NODETYPE_ANY), (int)HAPI_NodeFlags.HAPI_NODEFLAGS_NETWORK, true, ref nodeCount))
	    {
		return false;
	    }

	    HAPI_NodeId[] nodeIDs = new HAPI_NodeId[nodeCount];
	    if (!session.GetComposedChildNodeList(_assetID, nodeIDs, nodeCount))
	    {
		return false;
	    }

	    // Holds TOP networks in use
	    List<HEU_TOPNetworkData> newNetworks = new List<HEU_TOPNetworkData>();

	    // For each network, only add those with TOP child nodes (therefore guaranteeing only TOP networks are added).
	    for (int t = 0; t < nodeCount; ++t)
	    {
		HAPI_NodeInfo topNodeInfo = new HAPI_NodeInfo();
		if (!session.GetNodeInfo(nodeIDs[t], ref topNodeInfo))
		{
		    return false;
		}

		string nodeName = HEU_SessionManager.GetString(topNodeInfo.nameSH, session);
		//Debug.LogFormat("Top node: {0} - {1}", nodeName, topNodeInfo.type);

		// Skip any non TOP or SOP networks
		if (topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_TOP && topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_SOP)
		{
		    continue;
		}

		// Get list of all TOP nodes within this network.
		HAPI_NodeId[] topNodeIDs = null;
		if (!HEU_SessionManager.GetComposedChildNodeList(session, nodeIDs[t], (int)(HAPI_NodeType.HAPI_NODETYPE_TOP), (int)HAPI_NodeFlags.HAPI_NODEFLAGS_TOP_NONSCHEDULER, true, out topNodeIDs))
		{
		    continue;
		}

		// Skip networks without TOP nodes
		if (topNodeIDs == null || topNodeIDs.Length == 0)
		{
		    continue;
		}

		// Get any filter tags from spare parms on TOP nodes
		TOPNodeTags tags = new TOPNodeTags();
		if (_useHEngineData)
		{
		    ParseHEngineData(session, nodeIDs[t], ref topNodeInfo, ref tags);

		    if (!tags._show)
		    {
			continue;
		    }
		}
		else
		{
		    tags._show = true;
		}

		HEU_TOPNetworkData topNetworkData = GetTOPNetworkByName(nodeName, _topNetworks);
		if (topNetworkData == null)
		{
		    topNetworkData = new HEU_TOPNetworkData();
		}
		else
		{
		    // Found previous TOP network, so remove it from old list. This makes
		    // sure to not remove it when cleaning up old nodes.
		    _topNetworks.Remove(topNetworkData);
		}

		newNetworks.Add(topNetworkData);

		topNetworkData._nodeID = nodeIDs[t];
		topNetworkData._nodeName = nodeName;
		topNetworkData._parentName = _assetName;
		topNetworkData._tags = tags;

		PopulateTOPNodes(session, topNetworkData, topNodeIDs, _useHEngineData);
	    }

	    // Clear old TOP networks and nodes
	    ClearAllTOPData();
	    _topNetworks = newNetworks;

	    // Update latest TOP network names
	    _topNetworkNames = new string[_topNetworks.Count];
	    for (int i = 0; i < _topNetworks.Count; ++i)
	    {
		_topNetworkNames[i] = _topNetworks[i]._nodeName;
	    }

	    return true;
	}
Пример #18
0
	/// <summary>
	/// Displays a dropdown list of TOP nodes, and shows the selected TOP node info
	/// </summary>
	private void DrawSelectedTOPNode()
	{
	    HEU_TOPNetworkData topNetworkData = _assetLink.GetSelectedTOPNetwork();
	    if (topNetworkData == null)
	    {
		return;
	    }

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		int numTopNodes = topNetworkData._topNodeNames.Length;
		if (numTopNodes > 0)
		{
		    using (new EditorGUILayout.HorizontalScope())
		    {
			EditorGUILayout.PrefixLabel(_topNodeChooseLabel);

			int selectedIndex = Mathf.Clamp(topNetworkData._selectedTOPIndex, 0, numTopNodes);
			int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, topNetworkData._topNodeNames);
			if (newSelectedIndex != selectedIndex)
			{
			    _assetLink.SelectTOPNode(topNetworkData, newSelectedIndex);
			}
		    }
		}
		else
		{
		    EditorGUILayout.PrefixLabel(_topNodeNoneLabel);
		}

		EditorGUILayout.Space();

		HEU_TOPNodeData topNode = _assetLink.GetSelectedTOPNode();
		if (topNode != null)
		{
		    topNode._tags._autoload = EditorGUILayout.Toggle(_autoloadContent, topNode._tags._autoload);

		    bool showResults = topNode._showResults;
		    showResults = EditorGUILayout.Toggle(_showHideResultsContent, showResults);
		    if (showResults != topNode._showResults)
		    {
			topNode._showResults = showResults;
			_assetLink.UpdateTOPNodeResultsVisibility(topNode);
		    }

		    EditorGUILayout.Space();

		    using (new EditorGUILayout.HorizontalScope())
		    {
			if (GUILayout.Button(_buttonDirtyContent))
			{
			    _assetLink.DirtyTOPNode(topNode);
			}

			if (GUILayout.Button(_buttonCookContent))
			{
			    _assetLink.CookTOPNode(topNode);
			}
		    }

		    EditorGUILayout.Space();

		    using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
		    {
			EditorGUILayout.LabelField("TOP Node State: " + _assetLink.GetTOPNodeStatus(topNode));

			EditorGUILayout.Space();

			EditorGUILayout.LabelField(_topNodeStatusLabel);
			DrawWorkItemTally(topNode._workItemTally);
		    }
		}
	    }
	}
	/// <summary>
	/// Given TOP nodes from a TOP network, populate internal state from each TOP node.
	/// </summary>
	/// <param name="session">Houdini Engine session</param>
	/// <param name="topNetwork">TOP network to query TOP nodes from</param>
	/// <param name="topNodeIDs">List of TOP nodes in the TOP network</param>
	/// <param name="useHEngineData">Whether or not to use HEngine data for filtering</param>
	/// <returns>True if successfully populated data</returns>
	private bool PopulateTOPNodes(HEU_SessionBase session, HEU_TOPNetworkData topNetwork, HAPI_NodeId[] topNodeIDs, bool useHEngineData)
	{
	    // Holds list of found TOP nodes
	    List<HEU_TOPNodeData> newNodes = new List<HEU_TOPNodeData>();

	    foreach (HAPI_NodeId topNodeID in topNodeIDs)
	    {
		// Not necessary. Blocks main thread.
		//session.CookNode(childNodeID, HEU_PluginSettings.CookTemplatedGeos);

		HAPI_NodeInfo childNodeInfo = new HAPI_NodeInfo();
		if (!session.GetNodeInfo(topNodeID, ref childNodeInfo))
		{
		    return false;
		}

		string nodeName = HEU_SessionManager.GetString(childNodeInfo.nameSH, session);
		//HEU_Logger.LogFormat("TOP Node: name={0}, type={1}", nodeName, childNodeInfo.type);

		TOPNodeTags tags = new TOPNodeTags();
		if (useHEngineData)
		{
		    ParseHEngineData(session, topNodeID, ref childNodeInfo, ref tags);

		    if (!tags._showHEngineData)
		    {
			continue;
		    }
		}
		else
		{
		    tags._show = true;
		    tags._showHEngineData = true;
		}

		HEU_TOPNodeData topNodeData = GetTOPNodeByName(nodeName, topNetwork._topNodes);
		if (topNodeData == null)
		{
		    topNodeData = new HEU_TOPNodeData();
		}
		else
		{
		    topNetwork._topNodes.Remove(topNodeData);
		}

		newNodes.Add(topNodeData);

		//topNodeData.Reset();
		topNodeData._nodeID = topNodeID;
		topNodeData._nodeName = nodeName;
		topNodeData._parentName = topNetwork._parentName + "_" + topNetwork._nodeName;
		topNodeData._tags = tags;

		// Note: Don't have to compare with _showHEngineData because it won't exist in network if false
		if (_bUseTOPOutputFilter && _topNodeFilter != "")
		{
		    if (!nodeName.StartsWith(_topNodeFilter))
		    {
			topNodeData._tags._show = false;
		    }
		}

		if (_bUseTOPOutputFilter)
		{
		    bool bAutoLoad = false;
		    if (_topOutputFilter == "")
		    {
			bAutoLoad = true;
		    }
		    else if (nodeName.StartsWith(_topOutputFilter))
		    {
			bAutoLoad = true;
		    }

		    topNodeData._tags._autoload |= bAutoLoad;
		    topNodeData._showResults = topNodeData._tags._autoload;
		}
	    }

	    // Clear old unused TOP nodes
	    for (int i = 0; i < topNetwork._topNodes.Count; ++i)
	    {
		ClearTOPNodeWorkItemResults(topNetwork._topNodes[i]);
	    }
	    topNetwork._topNodes = newNodes;

	    // Get list of updated TOP node names
	    SetupTopNetworkNames(topNetwork);

	    return true;
	}
Пример #20
0
	/// <summary>
	/// Displays a dropdown list of TOP nodes, and shows the selected TOP node info
	/// </summary>
	private void DrawSelectedTOPNode()
	{
	    HEU_TOPNetworkData topNetworkData = _assetLink.GetSelectedTOPNetwork();
	    if (topNetworkData == null)
	    {
		return;
	    }

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		List<KeyValuePair<int, HEU_TOPNodeData>> displayNodeData = _assetLink.GetNonHiddenTOPNodes(topNetworkData);
		int numTopNodes = displayNodeData.Count;
		if (numTopNodes > 0)
		{
		    using (new EditorGUILayout.HorizontalScope())
		    {
			EditorGUILayout.PrefixLabel(_topNodeChooseLabel);

			int currentSelectedIndex = -1;
			for (int i = 0; i < displayNodeData.Count; i++)
			{
			    if (displayNodeData[i].Key == topNetworkData._selectedTOPIndex)
			    {
				currentSelectedIndex = i;
				break;
			    }
			}

			int selectedIndex = Mathf.Clamp(currentSelectedIndex, 0, displayNodeData.Count);
			int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, topNetworkData._topNodeNames);
			if (newSelectedIndex != selectedIndex)
			{
			    _assetLink.SelectTOPNode(topNetworkData, displayNodeData[newSelectedIndex].Key);
			}
		    }
		}
		else
		{
		    EditorGUILayout.PrefixLabel(_topNodeNoneLabel);
		}

		EditorGUILayout.Space();

		HEU_TOPNodeData topNode = _assetLink.GetSelectedTOPNode();
		if (topNode != null)
		{
		    topNode._tags._autoload = EditorGUILayout.Toggle(_autoloadContent, topNode._tags._autoload);

		    bool showResults = topNode._showResults;
		    showResults = EditorGUILayout.Toggle(_showHideResultsContent, showResults);
		    if (showResults != topNode._showResults)
		    {
			topNode._showResults = showResults;
			_assetLink.UpdateTOPNodeResultsVisibility(topNode);
		    }

		    EditorGUILayout.Space();

		    using (new EditorGUILayout.HorizontalScope())
		    {
			if (GUILayout.Button(_buttonDirtyContent))
			{
			    _assetLink.DirtyTOPNode(topNode);
			}

			if (GUILayout.Button(_buttonCookContent))
			{
			    _assetLink.CookTOPNode(topNode);
			}
		    }

		    EditorGUILayout.Space();

		    using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
		    {
			EditorGUILayout.LabelField("TOP Node State: " + _assetLink.GetTOPNodeStatus(topNode));

			EditorGUILayout.Space();

			EditorGUILayout.LabelField(_topNodeStatusLabel);
			DrawWorkItemTally(topNode._workItemTally);
		    }
		}
	    }
	}