Beispiel #1
0
 private void OnEnable()
 {
     myTarget    = (PiUI)target;
     addSlice    = AddSlice;
     removeSlice = SliceToRemove;
     angleUpdate = AngleUpdate;
 }
Beispiel #2
0
    private void Start()
    {
        _cameraController = FindObjectOfType <cameraController>();

        piUi       = FindObjectOfType <PiUIManager>();
        normalMenu = piUi.GetPiUIOf("Normal Menu");
        //piUi.ChangeMenuState("Normal Menu", new Vector2(Screen.width / 2f, Screen.height / 2f));
    }
Beispiel #3
0
 private void OnEnable()
 {
     myTarget       = (PiUI)target;
     addSlice       = AddSlice;
     removeSlice    = SliceToRemove;
     angleUpdate    = AngleUpdate;
     itemsNotToDraw = new List <string>();
 }
Beispiel #4
0
    /// <summary>
    /// Will open/close the menu name passed at the position passed.
    /// </summary>
    /// <param name="menuName">Menu to open or close.</param>
    /// <param name="pos">Position to open menu.</param>
    public void ChangeMenuState(string menuName, Vector2 pos = default(Vector2))
    {
        PiUI currentPi = GetPiUIOf(menuName);

        if (currentPi.openedMenu)
        {
            currentPi.CloseMenu( );
        }
        else
        {
            currentPi.OpenMenu(pos);
        }
    }
Beispiel #5
0
    private void Start()
    {
        roomUIController.GetComponent <CanvasGroup>().alpha = 0;

        poiSizeMenu        = piUIManager.GetPiUIOf("Poi Size Menu");
        poiPersonalityMenu = piUIManager.GetPiUIOf("Poi Personality Menu");
        poiNoteMenu        = piUIManager.GetPiUIOf("Poi Note Menu");
        EditPoiMenus();

        quitButton.onClick.AddListener(Application.Quit);
        addPoiButton.onClick.AddListener(ShowPoiPersonalityMenu);
        randomPoiButton.onClick.AddListener(delegate { SpawnNewPoi(null, true); });
    }
    void Start()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        _inventoryMenu     = GetComponentInChildren <PiUI>();
        _characterMovement = GetComponent <CharacterMovement>();
        _characterWeapon   = GetComponent <CharacterWeapon>();
        _cameraController  = GetComponent <CameraController>();
        SetItem(1);

        _inventoryMenu.dynamicallyScaleToResolution = true;
    }
    public void SetData(PiUI.PiData piData, float iR, float oR, PiUI creator)
    {
        parent = creator;
        if (!thisImg || !sliceIcon || !sliceLabel)
        {
            thisImg    = GetComponent <Image>( );
            sliceIcon  = transform.GetChild(0).GetComponent <Image>( );
            sliceLabel = GetComponentInChildren <Text>( );
        }
        innerRadius    = iR;
        outerRadius    = oR;
        normalColor    = piData.nonHighlightedColor;
        highlightColor = piData.highlightedColor;
        disabledColor  = piData.disabledColor;
        clickEvent     = piData.onSlicePressed;
        //new
        id          = piData.id;
        onClickMenu = piData.onClickMenu;

        if (parent.fade)
        {
            thisImg.color = Color.clear;
        }
        maxAngle = transform.rotation.eulerAngles.z;
        minAngle = transform.rotation.eulerAngles.z - (thisImg.fillAmount * 360);
        if (transform.rotation.eulerAngles.z == 359f || transform.rotation.eulerAngles.z == 0)
        {
            transform.rotation = Quaternion.identity;
            maxAngle           = 359f;
            minAngle           = 359f - (thisImg.fillAmount * 360);
        }
        sliceIcon.rectTransform.sizeDelta = new Vector2(piData.iconSize, piData.iconSize);

        sliceLabel.text               = piData.sliceLabel;
        sliceIcon.sprite              = piData.icon;
        sliceIcon.transform.position  = Center( );
        sliceLabel.transform.position = Center( ) - new Vector2(0, sliceIcon.rectTransform.sizeDelta.y + parent.textVerticalOffset) * parent.scaleModifier * transform.localScale.magnitude;
        isInteractable = piData.isInteractable;
        onHoverEvents  = piData.hoverFunctions;
        if (onHoverEvents)
        {
            onHoverEnter = piData.onHoverEnter;
            onHoverExit  = piData.onHoverExit;
        }
    }
Beispiel #8
0
        public void OnInspectorGUI(SerializedProperty sprop, PiUI menu, System.Action AddSlice, System.Action <PiData> RemoveSlice, System.Action <int> angleUpdate)
        {
            float angleStart = angle;

            if (icon == null)
            {
                icon = Sprite.Create(angleTexture, new Rect(0, 0, angleTextureSize, angleTextureSize), Vector2.zero, 0, 0, SpriteMeshType.FullRect, Vector4.zero, false);
            }
            order = Mathf.Clamp(order, 0, menu.piData.Length);
            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.BeginHorizontal();
            if (order > 0 && GUILayout.Button("▲", GUILayout.Width(32)))
            {
                order = Mathf.Clamp(order - 1, 0, menu.piData.Length);
                foreach (PiData pi in menu.piData)
                {
                    if (pi != this && pi.order == order)
                    {
                        pi.order = Mathf.Clamp(pi.order + 1, 0, menu.piData.Length);
                        break;
                    }
                }
            }
            if (order < menu.piData.Length - 1 && GUILayout.Button("▼", GUILayout.Width(32)))
            {
                order = Mathf.Clamp(order + 1, 0, menu.piData.Length);
                foreach (PiData pi in menu.piData)
                {
                    if (pi != this && pi.order == order)
                    {
                        pi.order = Mathf.Clamp(pi.order - 1, 0, menu.piData.Length);
                        break;
                    }
                }
            }
            sliceLabel          = EditorGUILayout.TextField(sliceLabel);
            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("+", GUILayout.Width(32)))
            {
                AddSlice.Invoke();
            }
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("-", GUILayout.Width(32)))
            {
                RemoveSlice.Invoke(this);
            }
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            var rect = EditorGUILayout.GetControlRect(GUILayout.Width(64), GUILayout.Height(64));

            if (icon != null)
            {
                GUI.DrawTexture(rect, Texture2D.blackTexture, ScaleMode.ScaleToFit);

                GUI.DrawTexture(rect, icon.texture, ScaleMode.ScaleToFit);
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Space(8);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Icon", GUILayout.Width(96));
            icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), false, GUILayout.Height(16));
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical();
            if (!menu.syncColors)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Non Selected Color");
                nonHighlightedColor = EditorGUILayout.ColorField(nonHighlightedColor, GUILayout.Height(16), GUILayout.Width(50));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Selected Color");
                highlightedColor = EditorGUILayout.ColorField(highlightedColor, GUILayout.Height(16), GUILayout.Width(50));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Not Interactable Color");
                disabledColor = EditorGUILayout.ColorField(disabledColor, GUILayout.Height(16), GUILayout.Width(50));
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            if (!menu.equalSlices)
            {
                angle = EditorGUILayout.FloatField("Angle", angle, GUILayout.Width(192));
                GUILayout.FlexibleSpace();
            }
            Rect angleRect = EditorGUILayout.GetControlRect(GUILayout.Width(32), GUILayout.Height(32));

            GUI.DrawTexture(angleRect, angleTexture, ScaleMode.ScaleToFit);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Icon Size", GUILayout.Width(96));
            iconSize = EditorGUILayout.IntField(iconSize);
            if (iconSize < 8)
            {
                iconSize = 8;
            }
            else if (iconSize > 256)
            {
                iconSize = 256;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Interactable ?", GUILayout.Width(96));
            isInteractable = EditorGUILayout.Toggle(isInteractable);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            EditorGUI.indentLevel++;
            hoverFunctions = EditorGUILayout.Foldout(hoverFunctions, "Hover Events", true);
            EditorGUI.indentLevel--;

            if (hoverFunctions)
            {
                EditorGUILayout.PropertyField(sprop.FindPropertyRelative("onHoverEnter"));
                EditorGUILayout.PropertyField(sprop.FindPropertyRelative("onHoverExit"));
            }
            EditorGUILayout.PropertyField(sprop.FindPropertyRelative("onSlicePressed"));
            GUILayout.Label(order.ToString(), GUILayout.Width(10));

            GUILayout.EndVertical();
            if (!menu.equalSlices && angle != angleStart)
            {
                angleUpdate.Invoke(order);
            }

            angleTexture = new Texture2D(angleTextureSize, angleTextureSize);
            Color32 resetColor = new Color32(255, 255, 255, 0);

            Color32[] resetColorArray = angleTexture.GetPixels32();

            float sumOfBefore = (360f / menu.piData.Length) * order;
            float endAngle    = (360f / menu.piData.Length) * (order + 1);

            for (int i = 0; i < resetColorArray.Length; i++)
            {
                resetColorArray[i] = resetColor;
            }
            angleTexture.SetPixels32(resetColorArray);
            angleTexture.Apply();
            if (!menu.equalSlices)
            {
                sumOfBefore = 0;
                for (int i = 0; i < order; i++)
                {
                    sumOfBefore += menu.piData[i].angle;
                }
                endAngle = sumOfBefore + angle;
            }
            Vector2 origin = new Vector2(angleTextureSize / 2, angleTextureSize / 2);

            for (int i = Mathf.RoundToInt(sumOfBefore); i <= Mathf.Round(endAngle); i++)
            {
                Vector2 dir = new Vector2(Mathf.Cos(i * Mathf.Deg2Rad), Mathf.Sin(i * Mathf.Deg2Rad));
                dir.Normalize();
                for (int j = 0; j < angleTextureSize / 2; j++)
                {
                    Vector2 temp = dir * j;
                    temp += origin;
                    if (j != (angleTextureSize / 2) - 1)
                    {
                        angleTexture.SetPixel(Mathf.RoundToInt(temp.x), Mathf.RoundToInt(temp.y), Color.white);
                    }
                }
            }
            angleTexture.Apply();
        }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     //Get menu for easy not repetitive getting of the menu when setting joystick input
     normalMenu = piUi.GetPiUIOf("Normal Menu");
 }