Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            _picker.Draw(style);

            GUILayout.Space(5);
            UIStar b = style as UIStar;

            if (b != null)
            {
                EditorGUI.BeginChangeCheck();

                b.numStars    = EditorGUILayout.DelayedIntField("Number Stars", b.numStars);
                b.maxColumn   = EditorGUILayout.DelayedIntField("Max Column ", b.maxColumn);
                b.activeValue = EditorGUILayout.DelayedIntField("Active Value", b.activeValue);

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(b);
                }
            }

            GUILayout.Space(10);
        }
Esempio n. 2
0
    private void CreateUIStarsBar()
    {
        if (LevelsManager.CurrentLevel == null)
        {
            return;
        }
        if (UIStars != null)
        {
            //TODO: this part can be avoided by reusing stars that had been created, (We're better off not creating and destroying objects willy-nilly )
            for (int i = 0; i < UIStars.Length; i++)
            {
                if (UIStars[i] != null)
                {
                    GameObject.Destroy(UIStars[i].gameObject);
                }
            }
        }

        RectTransform scoreSliderRectTransform = scoreSliderFill.GetComponent(typeof(RectTransform)) as RectTransform;

        UIStars = new UIStar[LevelsManager.CurrentLevel.StarRequirements.Length];
        //stars = new UIStar[3];
        for (int i = 0; i < UIStars.Length; i++)
        {
            float xPosition =
                ((float)LevelsManager.CurrentLevel.StarRequirements[i] * scoreSliderRectTransform.rect.width)
                - (scoreSliderRectTransform.rect.width / 2);
            UIStar newStar = Instantiate(UIStarPrefab);
            newStar.transform.SetParent(scoreSliderFill.transform);
            //newStar.transform.parent = scoreSlider.transform;
            newStar.rectTransform.localPosition = new Vector2(xPosition, 0 + StarYOffset);
            newStar.rectTransform.localScale    = new Vector3(1, 1, 1);
            newStar.gameObject.SetActive(true);// the objects are not active when instantiated for some reason...
            UIStars[i] = newStar;
        }
    }