コード例 #1
0
        public override IEnumerator Auth(string key)
        {
            var settings = this.serviceManager.settings as GameDataSettings;

            return(this.GetData(settings.url, (result) => {
                if (result.hasError == false)
                {
                    GameDataSystem.TryToSaveCSV(result.data);
                }
                else
                {
                    GameDataSystem.TryToLoadCache();
                }
            }));
        }
コード例 #2
0
        public override System.Collections.Generic.IEnumerator <byte> Auth(string key, ServiceItem serviceItem)
        {
            var settings = this.serviceManager.settings as GameDataSettings;

            return(this.GetData(settings, (result) => {
                if (result.hasError == false)
                {
                    GameDataSystem.TryToSaveCSV(result.data);
                }
                else
                {
                    Debug.LogError(string.Format("[ GameData.GoogleService ] CSV GetData error: {0}", result.errorText));
                    GameDataSystem.TryToLoadCache();
                }
            }));
        }
コード例 #3
0
        public static void Draw(Rect position, SerializedProperty property, GUIContent label)
        {
            if (Application.isPlaying == false)
            {
                GameDataSystem.TryToLoadCache();
            }

            //property.serializedObject.Update();

            var keyProperty = property.FindPropertyRelative("key");

            if (keyProperty != null)
            {
                //GUILayout.BeginHorizontal();
                {
                    var labelWidth = EditorGUIUtility.labelWidth;
                    var offset     = new Vector2(-23f - 100f - labelWidth, -7f - 16f);

                    var indent = EditorGUI.indentLevel * 16f;

                    GUI.Label(new Rect(position.x + indent, position.y, labelWidth - indent, position.height), label);

                    var buttonRect = new Rect(position.x + labelWidth, position.y, position.width - labelWidth, position.height);

                    var style = ME.Utilities.CacheStyle("GameDataKeyDrawer.TextStyle", "inputField", (name) => {
                        var _style      = new GUIStyle(EditorStyles.textField);
                        _style.richText = true;
                        return(_style);
                    });

                    var keyValue = keyProperty.stringValue;
                    var keyFull  = string.Format("[<color=green><b>{1}</b></color>] {0}", keyValue, GameDataSystem.Get(keyValue, GameDataSystem.DEFAULT_EDITOR_VERSION));
                    if (GUI.Button(buttonRect, keyFull, style) == true)
                    {
                        var     rect   = position;
                        Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));
                        rect.x = vector.x;
                        rect.y = vector.y;

                        var popup = new Popup()
                        {
                            title = "GameData Keys", screenRect = new Rect(rect.x + labelWidth + offset.x, rect.y + rect.height + offset.y, rect.width - labelWidth - offset.x, 200f), searchText = keyProperty.stringValue, separator = '|'
                        };
                        popup.ItemByPath("None", () => {
                            keyProperty.serializedObject.Update();
                            keyProperty.stringValue = string.Empty;
                            keyProperty.serializedObject.ApplyModifiedProperties();

                            EditorUtility.SetDirty(keyProperty.serializedObject.targetObject);
                        });

                        foreach (var key in GameDataSystem.GetKeys())
                        {
                            var finalKey     = key;
                            var finalKeyFull = string.Format("{0} <color=grey>({1})</color>", finalKey, GameDataSystem.Get(finalKey, GameDataSystem.DEFAULT_EDITOR_VERSION));
                            popup.ItemByPath(finalKeyFull, () => {
                                keyProperty.serializedObject.Update();
                                keyProperty.stringValue = finalKey;
                                keyProperty.serializedObject.ApplyModifiedProperties();

                                EditorUtility.SetDirty(keyProperty.serializedObject.targetObject);
                            });
                        }

                        popup.Show();
                    }

                    var textFieldRect = buttonRect;                    //GUILayoutUtility.GetLastRect();
                    EditorGUIUtility.AddCursorRect(textFieldRect, MouseCursor.Text);

                    const float sizeX = 32f;
                    const float sizeY = 16f;
                    HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX, textFieldRect.y, sizeX, sizeY), HierarchyEditor.colors.layoutElements, "GD");

                    if (GameDataSystem.ContainsKey(keyProperty.stringValue) == false)
                    {
                        HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX - 54f, textFieldRect.y, 54f, sizeY), HierarchyEditor.colors.error, "NO KEY");
                    }
                    else
                    {
                        HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX - 54f, textFieldRect.y, 54f, sizeY), HierarchyEditor.colors.components, GameDataSystem.DEFAULT_EDITOR_VERSION.ToString());
                    }
                }
                //GUILayout.EndHorizontal();
            }

            //property.serializedObject.ApplyModifiedProperties();
        }