protected void OnSceneGUI()
        {
            if (!this.m_DisplayGeometry)
            {
                return;
            }

            UICircularRaycastFilter filter = this.target as UICircularRaycastFilter;
            RectTransform           rt     = filter.transform as RectTransform;

            if (filter.operationalRadius == 0f)
            {
                return;
            }

            float   radius   = filter.operationalRadius;
            Vector3 position = rt.TransformPoint(new Vector3(rt.rect.center.x, rt.rect.center.y, 0f) + new Vector3(filter.offset.x, filter.offset.y, 0f));

            Canvas canvas = BaseUIUtils.FindInParents <Canvas>(filter.gameObject);

            if (canvas != null)
            {
                radius *= canvas.transform.localScale.x;
            }

            Handles.color = Color.green;
            Handles.CircleHandleCap(0, position, rt.rotation, radius, EventType.Repaint);
        }
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(pos, label, prop);

            // Draw label
            pos = EditorGUI.PrefixLabel(pos, GUIUtility.GetControlID(FocusType.Passive), label);

            // Don't make child fields be indented
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            float colorWidth = (pos.width - hexFieldWidth - spacing - alphaFieldWidth - spacing);

            Color32 color  = prop.colorValue;
            Color32 color2 = EditorGUI.ColorField(new Rect(pos.x, pos.y, colorWidth, pos.height), prop.colorValue);

            if (!color2.Equals(color))
            {
                prop.colorValue = color = color2;
            }

            string colorString = EditorGUI.TextField(new Rect((pos.x + colorWidth + spacing), pos.y, hexFieldWidth, pos.height), BaseUIUtils.ColorToString(color));

            try
            {
                color2 = BaseUIUtils.StringToColor(colorString);

                if (!color2.Equals(color))
                {
                    prop.colorValue = color = color2;
                }
            }
            catch { }


            float newAlpha = EditorGUI.Slider(new Rect((pos.x + colorWidth + hexFieldWidth + (spacing * 2f)), pos.y, alphaFieldWidth, pos.height), prop.colorValue.a, 0f, 1f);

            if (!newAlpha.Equals(prop.colorValue.a))
            {
                prop.colorValue = new Color(prop.colorValue.r, prop.colorValue.g, prop.colorValue.b, newAlpha);
            }

            // Set indent back to what it was
            EditorGUI.indentLevel = indent;

            EditorGUI.EndProperty();
        }
Example #3
0
        // ----------------------------------------------------------------------------
        // private methods
        // ----------------------------------------------------------------------------
        private void ConfigureCanvas()
        {
            Canvas parentCanvas = GetComponentInParent <Canvas>();

            if (parentCanvas != null)
            {
                externalCanvas = true;

                RectTransform ownRectTransform = gameObject.GetComponent <RectTransform>();
                if (ownRectTransform == null)
                {
                    ownRectTransform = gameObject.AddComponent <RectTransform>();
                }

                BaseUIUtils.ResetRectTransform(ownRectTransform);
            }

            GameObject canvasObject = new GameObject("CountersCanvas", typeof(Canvas));

            canvasObject.tag   = gameObject.tag;
            canvasObject.layer = gameObject.layer;
            canvasObject.transform.SetParent(transform, false);

            canvas = canvasObject.GetComponent <Canvas>();

            RectTransform canvasRectTransform = canvasObject.GetComponent <RectTransform>();

            BaseUIUtils.ResetRectTransform(canvasRectTransform);

            if (!externalCanvas)
            {
                canvas.renderMode   = RenderMode.ScreenSpaceOverlay;
                canvas.pixelPerfect = pixelPerfect;
                canvas.sortingOrder = sortingOrder;

                canvasScaler = canvasObject.AddComponent <CanvasScaler>();

                if (autoScale)
                {
                    canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
                }
                else
                {
                    canvasScaler.scaleFactor = scaleFactor;
                }
            }
        }
Example #4
0
 protected override void Awake()
 {
     base.Awake();
     if (RectTrans == null)
     {
         RectTrans = GetComponent <RectTransform>();
     }
     if (Presenter == null)
     {
         Presenter = GetComponent <BasePresenter>();
     }
     if (Presenter == null)
     {
         CLog.Error("UITransition 没有 Presenter:{0}", BaseUIUtils.GetPath(gameObject));
     }
     if (RectTrans != null)
     {
         Graphic = RectTrans.GetComponent <Graphic>();
         Effect  = RectTrans.GetComponent <BaseMeshEffect>();
     }
     if (Graphic != null)
     {
         if (Graphic is Text)
         {
             Text = (Text)Graphic;
         }
         if (Graphic is Image)
         {
             Image = (Image)Graphic;
         }
         RectTrans = Graphic.rectTransform;
     }
     if (Effect != null)
     {
         if (Effect is Shadow)
         {
             Shadow = (Shadow)Effect;
         }
         if (Effect is Outline)
         {
             Outline = (Outline)Effect;
         }
     }
 }
Example #5
0
 public override void InspectorExcude()
 {
     base.InspectorExcude();
     AppendInpsectorStr(BaseUIUtils.Percent(_prob.Value));
 }
Example #6
0
 public override void InspectorExcude()
 {
     base.InspectorExcude();
     AppendInpsectorStr(BaseUIUtils.Percent(_prob.Value) + " " + _action.Method.Name);
 }