コード例 #1
0
    void OnGUI()
    {
        //credit to SilverTabby on answers.unity3d.com for this
        //method of scaling GUI things
        float rx = Screen.width / native_width;
        float ry = Screen.height / native_height;

        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(rx, ry, 1));

        for (int i = 0; i < UI_Elements.Length; i++)
        {
            UI_Element cur  = UI_Elements[i];
            GUISkin    temp = GUI.skin;
            if (cur.skin != null)
            {
                GUI.skin = cur.skin;
            }

            if (cur.isJustText)
            {
                GUI.Label(new Rect(cur.left, cur.top, cur.width, cur.height), cur.name);
            }
            else if (cur.isNavigationButton)
            {
                if (GUI.Button(new Rect(cur.left, cur.top, cur.width, cur.height), cur.name))
                {
                    if (cur.isNavigationButton)
                    {
                        Application.LoadLevel(cur.scene_name);
                    }
                }
            }
            else
            {
                string val = player.getAttributeByName(cur.search_name);
                // TODO fix the above
//				string val = null;
                if (val != null)
                {
                    cur.value = val;
                    if (cur.isHUDImageDisplay)
                    {
                        GUI.Label(new Rect(cur.left, cur.top, cur.width, cur.height), cur.name + ":");
                        int parseHelper = 0;
                        int.TryParse(cur.value, out parseHelper);
                        for (int j = 0; j < parseHelper; j++)
                        {
                            GUI.DrawTexture(new Rect(cur.imageWidth * j + cur.left + cur.width, cur.top, cur.imageWidth, cur.imageHeight), cur.image);
                        }
                    }
                    else
                    {
                        val = cur.name + ": " + val;
                        GUI.Label(new Rect(cur.left, cur.top, cur.width, cur.height), val);
                    }
                }
            }
            GUI.skin = temp;
        }
    }
コード例 #2
0
 public void SetParentIfNotAlreadySet(UI_Element parent)
 {
     if (this.parent == null)
     {
         this.parent = parent;
     }
 }
コード例 #3
0
        public void RemoveLib(object sender)
        {
            UI_Element lib = sender as UI_Element;

            CompLibrary.AllUsedLibraries.RemoveAll(x => x.name == lib.parent.ID_Name);
            Reload_UI();
        }
コード例 #4
0
        public void DeleteLib(object sender)
        {
            UI_Element lib = sender as UI_Element;

            CompLibrary.LibraryWindow_LoadedLibraries.RemoveAll(x => x.name == lib.parent.ID_Name);
            Reload_UI();
        }
コード例 #5
0
    public void MoveToLayer(int index)
    {
        //Check if there is a layer selected.
        if (selectedLayer.layerName != "")
        {
            //Disable the current layer's element holder object.
            selectedElement.outlineObject.SetActive(false);
            selectedLayer.layerObject.SetActive(false);
        }

        //Loop through the layer array.
        for (int i = 0; i < layers.Length; i++)
        {
            //Check if the layer index is matching.
            if (layers[i].layerIndex == index)
            {
                //Update the selected layer and its corresponding elements.
                selectedLayer = layers[i];
                selectedLayer.layerObject.SetActive(true);
                selectedElement = layers[i].firstElement;
                selectedElement.outlineObject.SetActive(true);
                break;
            }
        }

        //Reset the hold timer.
        executionInputHoldTimer = 0f;
    }
コード例 #6
0
 public Pos(int XY, ORIGIN dest_origin = default(ORIGIN), ORIGIN src_origin = default(ORIGIN), UI_Element parent = null)
 {
     X_abs            = Y_abs = X = Y = XY;
     this.dest_origin = dest_origin;
     this.src_origin  = src_origin;
     this.parent      = parent;
     ego = null;
 }
コード例 #7
0
 public Pos(int X, int Y, ORIGIN dest_origin = default(ORIGIN), ORIGIN src_origin = default(ORIGIN), UI_Element parent = null)
 {
     this.X_abs       = this.X = X;
     this.Y_abs       = this.Y = Y;
     this.dest_origin = dest_origin;
     this.src_origin  = src_origin;
     this.parent      = parent;
     ego = null;
 }
コード例 #8
0
 private void Awake()
 {
     isActive = enabledObjects[0].activeInHierarchy;
     UI_Element[] childs = new UI_Element[transform.childCount];
     for (int i = 0; i < childs.Length; i++)
     {
         childs[i] = transform.GetChild(i).GetComponent <UI_Element>();
     }
     subElements = childs;
 }
コード例 #9
0
    public void ReceivePushNotification(RaycastHit hit, bool isHit)
    {
        if (isHit == true)
        {
            isLookingAt = true;
            //print("UI_Manager is looking at " + hit.transform.name);

            elementLookingAt = hit.transform.gameObject.GetComponent <UI_Element>();
        }
        else
        {
            isLookingAt = false;
        }
    }
コード例 #10
0
        public static void SetActivePanel(UI_Element element)
        {
            foreach (var panel in Instance.Panels.Values)
            {
                if (panel)
                {
                    panel.SetActive(false);
                }
            }

            if (Instance.Panels[element])
            {
                Instance.Panels[element].SetActive(true);
            }
        }
コード例 #11
0
    private void Start() // Adds
    {
        UI_Element interact  = new UI_Element(UI_element_names.Interact, interactElement);
        UI_Element putDown   = new UI_Element(UI_element_names.PutDown, putDownElement);
        UI_Element lightFire = new UI_Element(UI_element_names.LightFire, lightFireElement);
        UI_Element pickUp    = new UI_Element(UI_element_names.PickUp, pickUpElement);
        UI_Element place     = new UI_Element(UI_element_names.Place, placeElement);

        elements.Add(interact);
        elements.Add(putDown);
        elements.Add(lightFire);
        elements.Add(pickUp);
        elements.Add(place);
        StartCoroutine(DelayDeactivate());
    }
コード例 #12
0
    private void SetSelectedElement(bool upMovement)
    {
        AudioManager.Instance.PlayUISound(selectSound, selectVolume);

        //Check if there is a selected element that we can start from.
        if (selectedElement != null)
        {
            //Get the next UI element based on the given direction.
            UI_Element nextElement = upMovement ? selectedElement.elementAbove : selectedElement.elementBelow;

            //Check if there is a new element.
            if (nextElement != null)
            {
                //Disable the currently selected element's outline object, update the selected element and enable it's outline object in this exact order.
                selectedElement.outlineObject.SetActive(false);
                selectedElement = nextElement;
                selectedElement.outlineObject.SetActive(true);
            }

            //Reset the hold timer.
            executionInputHoldTimer = 0f;
        }

        //Selected element not specified.
        else
        {
            //Selected layer not specified. Returning to base layer.
            if (selectedLayer == null)
            {
                MoveToLayer(0);
            }

            //Update the selected element and it's outline object.
            selectedElement = selectedLayer.firstElement;
            selectedElement.outlineObject.SetActive(true);

            //Reset the hold timer.
            executionInputHoldTimer = 0f;
        }
    }
コード例 #13
0
    public void SetSelectedElement(UI_Element newElement)
    {
        //Disable the currently selected element's outline object.
        if (selectedElement != null)
        {
            if (selectedElement != newElement)
            {
                AudioManager.Instance.PlayUISound(selectSound, selectVolume);
            }
            selectedElement.outlineObject.SetActive(false);
        }

        else
        {
            AudioManager.Instance.PlayUISound(selectSound, selectVolume);
        }

        //Update the selected element and it's outline object.
        selectedElement = newElement;
        selectedElement.outlineObject.SetActive(true);

        //Reset the hold timer.
        executionInputHoldTimer = 0f;
    }
コード例 #14
0
 private void Awake()
 {
     _uiElement          = GetComponent <UI_Element>();
     _uiElement.turnOn  += TurnOn;
     _uiElement.turnOff += TurnOff;
 }