예제 #1
0
    IEnumerator Start()
    {
        LayoutAnchor anchor = GetComponent <LayoutAnchor>();

        while (true)
        {
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    TextAnchor a1 = (TextAnchor)i;
                    TextAnchor a2 = (TextAnchor)j;
                    Debug.Log(string.Format("A1:{0}   A2:{1}", a1, a2));
                    if (animated)
                    {
                        Tweener t = anchor.MoveToAnchorPosition(a1, a2, Vector2.zero);
                        while (t != null)
                        {
                            yield return(null);
                        }
                    }
                    else
                    {
                        anchor.SnapToAnchorPosition(a1, a2, Vector2.zero);
                    }
                    yield return(new WaitForSeconds(delay));
                }
            }
        }
    }
예제 #2
0
    IEnumerator Start()
    {
        LayoutAnchor anchor = GetComponent <LayoutAnchor>();

        while (true)
        {
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    // 정렬기준(좌, 우, 상, 하 조합)을
                    // 반복문으로 돌립니다.
                    TextAnchor a1 = (TextAnchor)i;
                    TextAnchor a2 = (TextAnchor)j;
                    Debug.Log(string.Format("A1:{0}   A2:{1}", a1, a2));

                    if (animated)
                    {
                        // animated가 true 이면 UI 가 이동하면서 좌표를 변경합니다.
                        Tweener t = anchor.MoveToAnchorPosition(a1, a2, Vector2.zero);
                        while (t != null)
                        {
                            yield return(null);
                        }
                    }
                    else
                    {
                        // animated가 false 이면 UI 가 순간이동합니다.
                        anchor.SnapToAnchorPosition(a1, a2, Vector2.zero);
                    }
                    yield return(new WaitForSeconds(delay));
                }
            }
        }
    }
예제 #3
0
 private void Awake()
 {
     anchor      = GetComponent <LayoutAnchor>();
     positionMap = new Dictionary <string, Position>(positionList.Count);
     for (int i = positionList.Count - 1; i >= 0; --i)
     {
         AddPosition(positionList[i]);
     }
 }
예제 #4
0
파일: Panel.cs 프로젝트: swejk/2DRPG
 void Awake()
 {
     anchor = GetComponent<LayoutAnchor>();
     positionMap = new Dictionary<string, Position>(positionList.Count);
     for (int i = positionList.Count - 1; i >= 0; --i)
     {
         AddPosition(positionList[i]);
     }
 }
예제 #5
0
        /// <summary>
        /// Change the grid collection's layout to the next one in order.
        /// </summary>
        public void NextLayout()
        {
            LayoutAnchor currentLayout   = grid.Anchor;
            var          anchorTypeCount = Enum.GetNames(typeof(LayoutAnchor)).Length;
            int          nextLayout      = (((int)currentLayout) + 1) % anchorTypeCount;

            grid.Anchor = (LayoutAnchor)nextLayout;
            UpdateUI();
        }
예제 #6
0
 /// <summary>
 /// Area with anchor and style.
 /// </summary>
 /// <param name="anchor"></param>
 public Area(LayoutAnchor anchor, Style style)
     : this(anchor)
 {
     if (!IsStyleCompatible(style))
     {
         throw new ArgumentException("Style is not compatible with area.");
     }
     this.style = style;
 }
예제 #7
0
 private void Awake()
 {
     anchor      = GetComponent <LayoutAnchor>();
     positionMap = new Dictionary <string, Position>(positionsList.Count); //Creates a new dictionary as long as the number of positions
     for (int i = positionsList.Count - 1; i >= 0; --i)
     {
         AddPosition(positionsList[i]);
     }
 }
예제 #8
0
        /// <summary>
        /// Change the grid's layout to the previous one in order.
        /// </summary>
        public void PreviousLayout()
        {
            LayoutAnchor currentLayout   = grid.Anchor;
            var          anchorTypeCount = Enum.GetNames(typeof(LayoutAnchor)).Length;
            int          nextLayout      = (((int)currentLayout) - 1) % anchorTypeCount;

            if (nextLayout < 0)
            {
                nextLayout += anchorTypeCount;
            }
            grid.Anchor = (LayoutAnchor)nextLayout;
            UpdateUI();
        }
예제 #9
0
 /// <summary>
 /// Creates a display object based button.
 /// </summary>
 /// <param name="displayObject"></param>
 public Button(LayoutAnchor anchor, IDisplayObject displayObject)
     : this(displayObject)
 {
     this.anchor = anchor;
 }
예제 #10
0
 /// <summary>
 /// Creates a label based button.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="labelStyle"></param>
 public Button(LayoutAnchor anchor, string text, Style labelStyle)
     : this(text, labelStyle)
 {
     this.anchor = anchor;
 }
예제 #11
0
 /// <summary>
 /// Area with anchor.
 /// </summary>
 /// <param name="anchor"></param>
 public Area(LayoutAnchor anchor)
     : this()
 {
     this.anchor = anchor;
 }
예제 #12
0
        protected Area(SerializationInfo info, StreamingContext context)
        {
            serializationOptions = (WidgetSerialization)info.GetValue("SerializeOptions", typeof(WidgetSerialization));
            zOrder      = info.GetUInt32("ZOrder");
            parent      = (IWidget)info.GetValue("Parent", typeof(IWidget));
            description = info.GetString("Description");
            containedDescriptionShowUpTime  = info.GetSingle("ContainedDescriptionShowUpTime");
            containedDescriptionPositioning = (LayoutAnchor)info.GetValue("ContainedDescriptionPositioning", typeof(LayoutAnchor));
            containedDescriptionObject      = (IDisplayObject)info.GetValue("ContainedDescriptionObject", typeof(IDisplayObject));
            anchor        = (LayoutAnchor)info.GetValue("Anchor", typeof(LayoutAnchor));
            minSize       = (GuiVector2)info.GetValue("MinSize", typeof(GuiVector2));
            maxSize       = (GuiVector2)info.GetValue("MaxSize", typeof(GuiVector2));
            preferredSize = (GuiVector2)info.GetValue("PreferredSize", typeof(GuiVector2));
            preserveRatio = info.GetBoolean("PreserveRatio");
            preferredRect = (GuiRect)info.GetValue("PreferredRect", typeof(GuiRect));
            marginLeft    = (GuiScalar)info.GetValue("MarginLeft", typeof(GuiScalar));
            marginRight   = (GuiScalar)info.GetValue("MarginRight", typeof(GuiScalar));
            marginTop     = (GuiScalar)info.GetValue("MarginTop", typeof(GuiScalar));
            marginBottom  = (GuiScalar)info.GetValue("MarginBottom", typeof(GuiScalar));

            if ((serializationOptions & WidgetSerialization.PersistAllStyles) > 0)
            {
                style = (Style)info.GetValue("Style", typeof(Style));
            }
            else if ((serializationOptions & WidgetSerialization.PersistNonThemeStyles) > 0)
            {
                style = (Style)info.GetValue("Style", typeof(Style));
            }

            if ((serializationOptions & WidgetSerialization.PersistRenderer) > 0)
            {
                renderer = (Themes.IGuiRenderer)info.GetValue("Renderer", typeof(Themes.IGuiRenderer));
            }

            if ((serializationOptions & WidgetSerialization.PersistState) > 0)
            {
                isVisible = info.GetBoolean("IsVisible");
            }

            if ((serializationOptions & WidgetSerialization.PersistAnimations) > 0)
            {
                animationState   = (StyleAnimationController)info.GetValue("StyleAnimationController", typeof(StyleAnimationController));
                activeAnimations = (List <AnimationProcess>)info.GetValue("ActiveAnimations", typeof(List <AnimationProcess>));
            }

            if ((serializationOptions & WidgetSerialization.PersistEventBindings) > 0)
            {
                onChange       = (Action <IPreChangeNotifier>)info.GetValue("OnChange", typeof(Action <IPreChangeNotifier>));
                onMouseOver    = (Action2 <Area, IPointer>)info.GetValue("OnMouseOver", typeof(Action2 <Area, IPointer>));
                onMouseLeave   = (Action2 <Area, IPointer>)info.GetValue("OnMouseLeave", typeof(Action2 <Area, IPointer>));
                onMousePressed = (Action4 <Area, IPointer, uint, InputEventModifier>)info.GetValue("OnMousePressed",
                                                                                                   typeof(Action4 <Area, IPointer, uint, InputEventModifier>));
                onMouseReleased = (Action3 <Area, IPointer, uint>)info.GetValue("OnMouseReleased", typeof(Action3 <Area, IPointer, uint>));
                onWheel         = (Action3 <Area, IPointer, float>)info.GetValue("OnWheel", typeof(Action3 <Area, IPointer, float>));
                onMouseMove     = (Action3 <Area, IPointer, Vector2f>)info.GetValue("OnMouseMove", typeof(Action3 <Area, IPointer, Vector2f>));
                onFocusGain     = (Action <Area>)info.GetValue("OnFocusGain", typeof(Action <Area>));
                onFocusLost     = (Action <Area>)info.GetValue("OnFocusLost", typeof(Action <Area>));
                onKeyPressed    = (Action5 <Area, IPointer, KeyCodes, KeyboardModifiers, InputEventModifier>)info.GetValue(
                    "OnKeyPressed", typeof(Action5 <Area, IPointer, KeyCodes, KeyboardModifiers, InputEventModifier>));
                onKeyReleased      = (Action4 <Area, IPointer, KeyCodes, KeyboardModifiers>)info.GetValue("OnKeyReleased", typeof(Action4 <Area, IPointer, KeyCodes, KeyboardModifiers>));
                onDescriptionShow  = (Action2 <Area, IWidget>)info.GetValue("OnDescriptionShow", typeof(Action2 <Area, IWidget>));
                onDescriptionHide  = (Action2 <Area, IWidget>)info.GetValue("OnDescriptionHide", typeof(Action2 <Area, IWidget>));
                onStyleStateChange = (Action3 <Area, StyleState, StyleState>)info.GetValue("OnStyleStateChange", typeof(Action3 <Area, StyleState, StyleState>));
            }
        }
        protected override void OnInspectorGUIInsertion()
        {
            EditorGUILayout.PropertyField(surfaceType);
            EditorGUILayout.PropertyField(orientType);
            EditorGUILayout.PropertyField(layout);



            LayoutOrder layoutTypeIndex = (LayoutOrder)layout.enumValueIndex;

            if (layoutTypeIndex == LayoutOrder.ColumnThenRow)
            {
                EditorGUILayout.HelpBox("ColumnThenRow will lay out content first horizontally (by column), then vertically (by row). NumColumns specifies number of columns per row.", MessageType.Info);
                EditorGUILayout.PropertyField(cols, new GUIContent("Num Columns", "Number of columns per row."));
                EditorGUILayout.PropertyField(columnAlignment);
            }
            else if (layoutTypeIndex == LayoutOrder.RowThenColumn)
            {
                EditorGUILayout.HelpBox("RowThenColumns will lay out content first vertically (by row), then horizontally (by column). NumRows specifies number of rows per column.", MessageType.Info);
                EditorGUILayout.PropertyField(rows, new GUIContent("Num Rows", "Number of rows per column."));
                EditorGUILayout.PropertyField(rowAlignment);
            }
            else
            {
                // do not show rows / cols field
            }

            if (layoutTypeIndex != LayoutOrder.Vertical)
            {
                EditorGUILayout.PropertyField(cellWidth);
            }
            if (layoutTypeIndex != LayoutOrder.Horizontal)
            {
                EditorGUILayout.PropertyField(cellHeight);
            }

            ObjectOrientationSurfaceType surfaceTypeIndex = (ObjectOrientationSurfaceType)surfaceType.enumValueIndex;

            if (surfaceTypeIndex == ObjectOrientationSurfaceType.Plane)
            {
                EditorGUILayout.PropertyField(distance, new GUIContent("Distance from parent", "Distance from parent object's origin"));
            }
            else
            {
                EditorGUILayout.PropertyField(radius);
                EditorGUILayout.PropertyField(radialRange);
            }

            if (surfaceTypeIndex != ObjectOrientationSurfaceType.Radial)
            {
                // layout anchor has no effect on radial layout, it is always at center.
                EditorGUILayout.PropertyField(anchor);
            }

            LayoutAnchor layoutAnchor = (LayoutAnchor)anchor.enumValueIndex;

            if (layoutAnchor != LayoutAnchor.MiddleCenter)
            {
                EditorGUILayout.PropertyField(anchorAlongAxis);
            }
        }