Example #1
0
    public override void OnInspectorGUI()
    {
        bool   isRefresh = false;
        UIBind bind      = target as UIBind;

        EditorGUILayout.BeginVertical(GUILayout.Width(600), GUILayout.Height(100));
        EditorGUILayout.LabelField("选择对应的类型");


        curBindType   = bind.BindType;
        bind.BindType = (BindType)EditorGUILayout.Popup(bind.BindType.GetHashCode(), bindTypeStrs, GUILayout.Width(100));
        if (curBindType != bind.BindType)
        {
            isRefresh = true;
        }

        curBindType = bind.BindType;


        switch (bind.BindType)
        {
        case BindType.Default:
            EditorGUILayout.LabelField("默认类型为:" + bind.DefaultName());
            bind.SelectTypeName = string.Empty;
            break;

        case BindType.Custom:
            curSelectType = bind.SelectTypeName;
            EditorGUILayout.BeginHorizontal(GUILayout.Width(600), GUILayout.Height(50));
            EditorGUILayout.LabelField("选择预定义Type:", GUILayout.Width(100));
            if (string.IsNullOrEmpty(bind.SelectTypeName))
            {
                bind.SelectTypeName = selectTypes[customTypeIndex];
            }
            customTypeIndex     = selectTypes.ToList().IndexOf(bind.SelectTypeName);
            customTypeIndex     = EditorGUILayout.Popup(customTypeIndex, selectTypes, GUILayout.Width(100));
            bind.SelectTypeName = selectTypes[customTypeIndex];
            if (curSelectType != bind.SelectTypeName)
            {
                isRefresh = true;
            }

            curSelectType = bind.SelectTypeName;
            EditorGUILayout.EndHorizontal();
            break;

        default:
            break;
        }

        EditorGUILayout.EndVertical();
        base.OnInspectorGUI();

        if (isRefresh)
        {
            Undo.RegisterCompleteObjectUndo(bind, "modify value");
            EditorUtility.SetDirty(bind);
            AssetDatabase.SaveAssets();
        }
    }
Example #2
0
    private void OnEnable()
    {
        Bind            = target as UIBind;
        SerializedValue = serializedObject.FindProperty("Value");

        Type type = Bind.GetWidgetClass();

        if (type == null)
        {
            return;
        }

        NodeOptions.Clear();

        var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

        for (int i = 0; i < fields.Length; ++i)
        {
            var      filed     = fields[i];
            object[] fieldAttr = filed.GetCustomAttributes(typeof(UiNameAttribute), true);
            if (fieldAttr.Length == 0)
            {
                continue;
            }

            UiNameAttribute attr    = fieldAttr[0] as UiNameAttribute;
            string          bindkey = string.IsNullOrEmpty(attr.Description) ? filed.Name : attr.Description;

            NodeOptions.Add(bindkey);
        }
    }
Example #3
0
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                subrootA  = uibind.AllObjs[0] as GameObject;
                subrootB  = uibind.AllObjs[1] as GameObject;
                subrootC4 = uibind.AllObjs[2] as GameObject;
            }
Example #4
0
            public void FillField()
            {
                UIBind uibind = GetComponent <UIBind>();

                rootRectTransform        = uibind.AllObjs[0] as RectTransform;
                BgUIEventTriggerListener = uibind.AllObjs[1] as UIEventTriggerListener;
                BgRectTransform          = uibind.AllObjs[2] as RectTransform;
                mapRectTransform         = uibind.AllObjs[3] as RectTransform;
            }
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                rootRectTransform        = uibind.AllObjs[0] as RectTransform;
                BgUIEventTriggerListener = uibind.AllObjs[1] as UIEventTriggerListener;
                BgRectTransform          = uibind.AllObjs[2] as RectTransform;
                mapRectTransform         = uibind.AllObjs[3] as RectTransform;
                CommonMiniMap            = uibind.AllObjs[4] as GameObject;
            }
Example #6
0
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                RulerRawImage         = uibind.AllObjs[0] as RawImage;
                Show                  = uibind.AllObjs[1] as GameObject;
                Mark                  = uibind.AllObjs[2] as GameObject;
                markRootRectTransform = uibind.AllObjs[3] as RectTransform;
                AngelTextUIText       = uibind.AllObjs[4] as UIText;
                markRoot              = uibind.AllObjs[5] as GameObject;
            }
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                MapNameUIText      = uibind.AllObjs[0] as UIText;
                RoomInfoUIText     = uibind.AllObjs[1] as UIText;
                NumberUIText       = uibind.AllObjs[2] as UIText;
                WinConditionUIText = uibind.AllObjs[3] as UIText;
                TeamUIText         = uibind.AllObjs[4] as UIText;
                Tip     = uibind.AllObjs[5] as GameObject;
                MapRoot = uibind.AllObjs[6] as GameObject;
            }
Example #8
0
    public UIPage(UIType type, UIMode mod, UICollider col, UITickedMode tickedMode = UITickedMode.None)
    {
        this.type     = type;
        this.mode     = mod;
        this.collider = col;
        this.name     = this.GetType().ToString();

        this.tickedMode = tickedMode;

        //when create one page.
        //bind special delegate .
        UIBind.Bind();
        //Debug.LogWarning("[UI] create page:" + ToString());
    }
Example #9
0
        private void OnEnable()
        {
            obj     = new SerializedObject(target);
            uiname  = obj.FindProperty("uiName");
            level   = obj.FindProperty("level");
            uiType  = obj.FindProperty("uiType");
            explain = obj.FindProperty("explain");
            parent  = obj.FindProperty("parentBind");
            UIBind bind = obj.targetObject as UIBind;

            uiname.stringValue          = target.name;
            uiType.enumValueIndex       = GetUITypeIndex(bind);
            parent.objectReferenceValue = parent.objectReferenceValue ?? GetUIBindParentTransform(bind);
            obj.ApplyModifiedProperties();
        }
Example #10
0
        /// <summary>
        /// 获取含有父级的Transform
        /// </summary>
        /// <param name="bind"></param>
        /// <returns></returns>
        private Transform GetUIBindParentTransform(UIBind bind)
        {
            Transform trans = bind.transform.parent;

            while (trans != null)
            {
                UIBind b = trans.GetComponent <UIBind>();
                if (b != null && b.level == UIBind.UILevel.UIElement)
                {
                    // 找出父级物体中离bind最近的一个UIBind
                    return(b.transform);
                }
                trans = trans.parent;
            }
            return(null);
        }
Example #11
0
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                MapNameUIText                        = uibind.AllObjs[0] as UIText;
                RoomInfoUIText                       = uibind.AllObjs[1] as UIText;
                NumberUIText                         = uibind.AllObjs[2] as UIText;
                WinConditionUIText                   = uibind.AllObjs[3] as UIText;
                TeamUIText                           = uibind.AllObjs[4] as UIText;
                TipUIText                            = uibind.AllObjs[5] as UIText;
                MapRoot                              = uibind.AllObjs[6] as GameObject;
                RoomInfoGroup                        = uibind.AllObjs[7] as GameObject;
                NumberGroup                          = uibind.AllObjs[8] as GameObject;
                WinConditionGroup                    = uibind.AllObjs[9] as GameObject;
                TeamGroup                            = uibind.AllObjs[10] as GameObject;
                TipGroup                             = uibind.AllObjs[11] as GameObject;
                GroupVerticalLayoutGroup             = uibind.AllObjs[12] as VerticalLayoutGroup;
                RoomInfoGroupVerticalLayoutGroup     = uibind.AllObjs[13] as VerticalLayoutGroup;
                WinConditionGroupVerticalLayoutGroup = uibind.AllObjs[14] as VerticalLayoutGroup;
            }
            public override void FillField()
            {
                base.FillField();
                UIBind uibind = GetComponent <UIBind>();

                rootRectTransform      = uibind.AllObjs[0] as RectTransform;
                HpGroup                = uibind.AllObjs[1] as GameObject;
                HpGroupInHurt          = uibind.AllObjs[2] as GameObject;
                currentHpSlider        = uibind.AllObjs[3] as Slider;
                curO2Image             = uibind.AllObjs[4] as Image;
                HelmetImage            = uibind.AllObjs[5] as Image;
                BulletproofImage       = uibind.AllObjs[6] as Image;
                PowerBarImageImage     = uibind.AllObjs[7] as Image;
                retreatBuffImage       = uibind.AllObjs[8] as Image;
                speedBuffImage         = uibind.AllObjs[9] as Image;
                PercentTextUIText      = uibind.AllObjs[10] as UIText;
                currentHpFillImage     = uibind.AllObjs[11] as Image;
                HpGroupInHurtFillImage = uibind.AllObjs[12] as Image;
                HeadIconImage          = uibind.AllObjs[13] as Image;
                ClothIconImage         = uibind.AllObjs[14] as Image;
                ShowPoseGroup          = uibind.AllObjs[15] as GameObject;
                currentPoseImage       = uibind.AllObjs[16] as Image;
            }
Example #13
0
        /// <summary>
        /// 根据物体上的UI类型,返回对应的UI类型枚举
        /// </summary>
        /// <param name="bind"></param>
        /// <returns></returns>
        private int GetUITypeIndex(UIBind bind)
        {
            int index = 0;

            if (bind.GetComponent <Text>() != null)
            {
                index = (int)UIBind.UIType.Text;
            }
            else if (bind.GetComponent <Button>() != null)
            {
                index = (int)UIBind.UIType.Button;
            }
            else if (bind.GetComponent <Toggle>() != null)
            {
                index = (int)UIBind.UIType.Toggle;
            }
            else if (bind.GetComponent <Slider>() != null)
            {
                index = (int)UIBind.UIType.Slider;
            }
            else if (bind.GetComponent <Scrollbar>() != null)
            {
                index = (int)UIBind.UIType.Scrollbar;
            }
            else if (bind.GetComponent <Dropdown>() != null)
            {
                index = (int)UIBind.UIType.Dropdown;
            }
            else if (bind.GetComponent <InputField>() != null)
            {
                index = (int)UIBind.UIType.InputField;
            }
            else if (bind.GetComponent <ScrollRect>() != null)
            {
                index = (int)UIBind.UIType.ScrollView;
            }
            else if (bind.GetComponent <Image>() != null)
            {
                index = (int)UIBind.UIType.Image;
            }
            else if (bind.GetComponent <RawImage>() != null)
            {
                index = (int)UIBind.UIType.RawImage;
            }
            else if (bind.GetComponent <Canvas>() != null)
            {
                index = (int)UIBind.UIType.Canvas;
            }
            else if (bind.GetComponent <RectTransform>() != null)
            {
                index = (int)UIBind.UIType.RectTransform;
            }
            else if (bind.GetComponent <Transform>() != null)
            {
                index = (int)UIBind.UIType.Transform;
            }
            else
            {
                index = (int)UIBind.UIType.GameObject;
            }
            return(index);
        }
 public void FillField()
 {
     UIBind uibind = GetComponent <UIBind>();
 }