예제 #1
0
    /// <summary>
    /// Add a context button to top level menu
    /// </summary>
    void AddContextButton(OVRInspectorContextDetails details)
    {
        OVRInspectorContextDetails detailsCopy = details;
        Button button = leftPanel.AddButton(details.GetName(), delegate(Button b) { SelectContextButton(detailsCopy, b); }, buttonPrefab);

        if (details == currentContext)
        {
            SelectContextButton(details, button);
        }
    }
예제 #2
0
    /// <summary>
    /// Register a new context for that will appear on the top level menu.
    /// </summary>
    /// <param name="context">Interface that will be used to build UI when this context is activated</param>
    /// <param name="subContextID">An ID that is passed back to the context. Useful if this interface supports more than one context</param>
    /// <param name="setCurrent">If true this context will be immediately activiated</param>
    public void RegisterContext(IOVRInspectorContext context, int subContextID, bool setCurrent = false)
    {
        OVRInspectorContextDetails contextDetails = new OVRInspectorContextDetails(context, subContextID);

        contextList.Add(contextDetails);
        if (currentContext == null || setCurrent)
        {
            ContextActivated(contextDetails);
        }
        UpdateTopMenu();
    }
예제 #3
0
 /// <summary>
 /// A context was activated
 /// </summary>
 void ContextActivated(OVRInspectorContextDetails contextDetails)
 {
     if (contextDetails != currentContext)
     {
         if (currentContext != null)
         {
             currentContext.SetContextActive(this, false);
         }
         currentContext = contextDetails;
         currentContext.SetContextActive(this, true);
         UpdateContextMenu();
     }
 }
예제 #4
0
    /// <summary>
    /// Handler for when a button is pressed
    /// </summary>
    void SelectContextButton(OVRInspectorContextDetails contextDetails, Button button = null)
    {
        if (lastSelectedContextButton)
        {
            lastSelectedContextButton.interactable = true;
        }
        lastSelectedContextButton = button;
        if (lastSelectedContextButton)
        {
            lastSelectedContextButton.interactable = false;
        }

        ContextActivated(contextDetails);
    }
예제 #5
0
 /// <summary>
 /// Add already attached contexts to the meny system
 /// </summary>
 void SetupAttachedContexts()
 {
     foreach (Transform child in controlsPanel.panel.transform)
     {
         if (!IsLabeledDontMove(child.gameObject))
         {
             OVRInspectorContextDetails contextDetails = new OVRInspectorContextDetails(child.gameObject);
             SetUIMaterials(child);
             contextList.Add(contextDetails);
             child.gameObject.SetActive(false);
         }
     }
     if (currentContext == null && contextList.Count > 0)
     {
         ContextActivated(contextList[0]);
     }
 }
예제 #6
0
    /// <summary>
    /// Load the panels under this transform as contexts selectable in the top level menu
    /// </summary>
    /// <param name="panel">The parent panel</param>
    /// <param name="markAsSceneSpecific">Should these be marked as scene-specific so we know to remove them later</param>
    void LoadPanels(Transform panel, bool markAsSceneSpecific)
    {
        List <Transform> children = new List <Transform>();

        foreach (Transform child in panel)
        {
            children.Add(child);
        }

        int prevNumContexts = contextList.Count;

        foreach (Transform child in children)
        {
            if (IsLabeledDontMove(child.gameObject))
            {
                continue;
            }
            CullPlatformSpecificObjects(child.gameObject);
            // Move to our main UI panel
            child.SetParent(controlsPanel.scrollingContent.transform, false);
            OVRInspectorContextDetails contextDetails = new OVRInspectorContextDetails(child.gameObject);
            contextList.Add(contextDetails);
            child.gameObject.SetActive(false);
            if (markAsSceneSpecific)
            {
                sceneSpecificContexts.Add(contextDetails);
            }
        }


        if (contextList.Count > prevNumContexts)
        {
            // Activate the first new context
            ContextActivated(contextList[prevNumContexts]);
        }

        // Make sure menu reflects items
        UpdateTopMenu();
    }