Beispiel #1
0
        public static void draw(Rect position, SerializedProperty property, GUIContent label)
        {
            int index = Array.FindIndex(getCardDefines(), c => c.id == property.intValue) + 1;

            //if (label.text.StartsWith("Element", StringComparison.OrdinalIgnoreCase))
            if (index == 0)
            {
                label.text = "None";
            }
            else
            {
                label.text = getCardDefines()[index - 1].GetType().Name;
            }
            if (GUI.Button(position, label))
            {
                if (UnityEngine.Event.current.button == 0)
                {
                    getMenu(property).DropDown(position);
                }
                else
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("ReloadCards"), false, () => EditorCardDefineHelper.loadCards());
                    menu.DropDown(position);
                }
            }
        }
Beispiel #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect rect = position;

            position = new Rect(rect.position, new Vector2(rect.width, EditorGUIUtility.singleLineHeight));
            //Folder
            property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label);
            position.y         += EditorGUIUtility.singleLineHeight;
            if (property.isExpanded)
            {
                //id
                position = EditorGUI.IndentedRect(position);
                SerializedProperty idProp = property.FindPropertyRelative("_id");
                if (idProp.intValue > 0)
                {
                    CardDefineIDPropDrawer.draw(position, idProp, new GUIContent(EditorCardDefineHelper.getCardDefine(idProp.intValue).GetType().Name));
                }
                else
                {
                    CardDefineIDPropDrawer.draw(position, idProp, new GUIContent("None"));
                }
                //int index = Array.FindIndex(getCardDefines(), c => c.id == idProp.intValue) + 1;
                //index = EditorGUI.Popup(position, nameof(CardSkinData.id), index, new string[] { "None" }.Concat(getCardDefines().Select(c => c.GetType().Name)).ToArray());
                //idProp.intValue = index == 0 ? -1 : getCardDefines()[index - 1].id;
                position.y += EditorGUIUtility.singleLineHeight;
                //image
                SerializedProperty imageProp = property.FindPropertyRelative("_" + nameof(CardSkinData.image));
                EditorGUI.PropertyField(position, imageProp);
                position.y += EditorGUIUtility.singleLineHeight;
                drawSprite(new Rect(position.x + position.width - 128, position.y, 128, 128), imageProp.objectReferenceValue as Sprite, new Vector2(128, 128));
                //GUI.Box(new Rect(position.x + position.width - 128, position.y, 128, 128), imageProp.objectReferenceValue == null ? null : (imageProp.objectReferenceValue as Sprite).texture);
                position.y += 128;
                //name
                SerializedProperty nameProp = property.FindPropertyRelative("_" + nameof(CardSkinData.name));
                position.height = EditorGUIUtility.singleLineHeight;
                EditorGUI.PropertyField(position, nameProp);
                position.y += EditorGUIUtility.singleLineHeight;
                //desc
                SerializedProperty descProp = property.FindPropertyRelative("_" + nameof(CardSkinData.desc));
                position.height = EditorGUIUtility.singleLineHeight * 4;
                EditorGUI.PrefixLabel(new Rect(position.x, position.y, position.width / 2, position.height), new GUIContent(nameof(CardSkinData.desc)));
                descProp.stringValue = EditorGUI.TextArea(new Rect(position.x + position.width / 2, position.y, position.width / 2, position.height), descProp.stringValue);
                position.y          += EditorGUIUtility.singleLineHeight * 4;
            }
        }
Beispiel #3
0
 static CardDefine[] getCardDefines()
 {
     return(EditorCardDefineHelper.getCardDefines());
 }