コード例 #1
0
        public override void OnEnter()
        {
            try
            {
                Dictionary <string, object> data;
                if (GDEDataManager.Get(ItemName.Value, out data))
                {
                    Vector3 val;
                    data.TryGetVector3(FieldName.Value, out val);
                    StoreResult.Value = val;
                }

                StoreResult.Value = GDEDataManager.GetVector3(FieldKey, StoreResult.Value);
            }
            catch (UnityException ex)
            {
                LogError(ex.ToString());
            }
            finally
            {
                Finish();
            }
        }
コード例 #2
0
        public override void OnEnter()
        {
            try
            {
                Dictionary <string, object> data;
                if (GDEDataManager.Get(ItemName.Value, out data))
                {
                    Material val;
                    data.TryGetMaterial(FieldName.Value, out val);
                    StoreResult.Value = val;
                }

                StoreResult.Value = GDEDataManager.GetUnityObject(ItemName.Value, FieldName.Value, StoreResult.Value as Material);
            }
            catch (UnityException ex)
            {
                Debug.LogError(ex.ToString());
            }
            finally
            {
                Finish();
            }
        }
コード例 #3
0
        public override void OnEnter()
        {
            try
            {
                Dictionary <string, object> data;
                if (GDEDataManager.Get(ItemName.Value, out data))
                {
                    string customKey;
                    data.TryGetString(FieldName.Value, out customKey);
                    customKey = GDEDataManager.GetString(ItemName.Value + "_" + FieldName.Value, customKey);

                    GDEDataManager.ResetToDefault(customKey, CustomField.Value);
                }
            }
            catch (UnityException ex)
            {
                LogError(string.Format(GDMConstants.ErrorResettingCustomValue, ItemName.Value, FieldName.Value, CustomField.Value));
                LogError(ex.ToString());
            }
            finally
            {
                Finish();
            }
        }
コード例 #4
0
        public override void OnEnter()
        {
            try
            {
                Dictionary <string, object> data;
                if (GDEDataManager.Get(ItemName.Value, out data))
                {
                    string val;
                    data.TryGetString(FieldName.Value, out val);
                    StoreResult.Value = val;
                }

                // Override with saved data value if it exists
                StoreResult.Value = GDEDataManager.GetString(ItemName.Value, FieldName.Value, StoreResult.Value);
            }
            catch (UnityException ex)
            {
                LogError(ex.ToString());
            }
            finally
            {
                Finish();
            }
        }
コード例 #5
0
        public override void OnEnter()
        {
            try
            {
                Dictionary <string, object> data;
                List <float> val = null;
                if (GDEDataManager.Get(ItemName.Value, out data))
                {
                    data.TryGetFloatList(FieldName.Value, out val);
                }

                // Override from saved data if it exists
                val = GDEDataManager.GetFloatList(ItemName.Value, FieldName.Value, val);
                StoreResult.SetArrayContents(val);
            }
            catch (UnityException ex)
            {
                LogError(ex.ToString());
            }
            finally
            {
                Finish();
            }
        }
コード例 #6
0
    protected virtual void OnDragDropRelease(GameObject surface)
    {
        var drags = GetComponentsInChildren <UIDragScrollView>();

        foreach (var d in drags)
        {
            d.scrollView = null;
        }

        Collider2D[] cols            = Physics2D.OverlapPointAll(new Vector2(mTrans.position.x, mTrans.position.y));
        float        zDepth          = 0;
        float        closestZDepth   = float.MaxValue;
        int          closestZDepthID = 0;

        for (int i = 0; i < cols.Length; i++)
        {
            //remove any collider which GO doesn't contain the tag 'Slot'
            if (cols[i].gameObject.tag != "Slot")
            {
                continue;
            }
            //collect all z-depths
            zDepth = cols[i].gameObject.transform.localPosition.z;

            //get closest z-depth index
            if (zDepth < closestZDepth)
            {
                closestZDepth   = zDepth;
                closestZDepthID = i;
            }
        }

        if (cols[closestZDepthID] && cols[closestZDepthID].gameObject.tag == "Slot")
        {
            try
            {
                GDEDataManager.SetString("DroppedSurface", "Value", cols[closestZDepthID].gameObject.name);
            } catch (UnityException ex)
            {
                UnityEngine.Debug.LogError(ex.ToString());
            }
        }

        if (mButton != null)
        {
            mButton.isEnabled = true;
        }
        else if (mCollider != null)
        {
            mCollider.enabled = true;
        }
        else if (mCollider2D != null)
        {
            mCollider2D.enabled = true;
        }

        UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

        if (container != null)
        {
            mTrans.parent = container.reparentTarget ?? container.transform;
        }
        else
        {
            mTrans.parent = mParent;
        }

        //mTrans.localPosition = Vector3.zero;

        foreach (Transform child in mTrans)
        {
            child.gameObject.SetActive(true);
        }

        if (mDragScrollView != null)
        {
            Invoke("EnableDragScrollView", 0.001f);
        }

        NGUITools.MarkParentAsChanged(gameObject);

        OnDragDropEnd();
    }
コード例 #7
0
        public override void OnEnter()
        {
            List <string> allItems      = new List <string>();
            string        currentSchema = "";

            foreach (KeyValuePair <string, object> pair in GDEDataManager.DataDictionary)
            {
                if (pair.Key.StartsWith(GDMConstants.SchemaPrefix))
                {
                    continue;
                }

                //skip if schema not specified
                if (!string.IsNullOrEmpty(searchInSchema.Value))
                {
                    //get all values of current Item
                    Dictionary <string, object> currentDataSet = pair.Value as Dictionary <string, object>;
                    //get Schema of current Item
                    currentDataSet.TryGetString(GDMConstants.SchemaKey, out currentSchema);
                    //check if current Schema equals specified one
                    if (currentSchema != searchInSchema.Value)
                    {
                        continue;
                    }
                }
                //add current Item to List
                allItems.Add(pair.Key);
            }

            hasItem.Value = allItems.Contains(itemName.Value);

            if (!string.IsNullOrEmpty(fieldName.Value))
            {
                try
                {
                    Dictionary <string, object> data;
                    if (GDEDataManager.Get(itemName.Value, out data))
                    {
                        string val;
                        data.TryGetString(fieldName.Value, out val);
                        result = val;
                    }

                    result = GDEDataManager.GetString(itemName.Value, fieldName.Value, result);

                    if (!string.IsNullOrEmpty(result))
                    {
                        hasResult.Value   = true;
                        storeResult.Value = result;
                    }
                    else
                    {
                        hasResult.Value = false;
                    }
                } catch (UnityException ex)
                {
                    UnityEngine.Debug.LogException(ex);
                }
            }

            Finish();
        }
コード例 #8
0
    public static void UpdateDataFromGDE()
    {
        // Debug.Log("Start updating data ...");

        // Debug.Log("Init GDE data ...");
        GDEDataManager.Init("gde_data");

        // Debug.Log("Start updating data of Hero ...");
        List <GDEHeroData> allHeroData = GDEDataManager.GetAllItems <GDEHeroData>();

        foreach (GDEHeroData oneData in allHeroData)
        {
            // get prefab
            string     fullPath = "Assets/Resources/" + oneData.PrefabPath + ".prefab";
            GameObject prefab   = AssetDatabase.LoadAssetAtPath(
                fullPath,
                typeof(GameObject)) as GameObject;
            GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab)
                                   as GameObject;

            Debug.Assert(prefab != null, "!!! Check Path <" + fullPath + "> !!!");

            Hero hero = newPrefab.GetComponent <Hero>();
            hero.m_MaxHP                 = oneData.MaxHP;
            hero.m_MoveVec               = oneData.MoveVec;
            hero.m_HurtProtectTime       = oneData.HurtProtect;
            hero.m_MAXShieldVal          = oneData.MaxShieldVal;
            hero.m_ShieldRestoreVec      = oneData.ShieldRestoreVec;
            hero.m_ShieldRestoreBreak    = oneData.ShieldRestoreBreak;
            hero.m_ShieldRestoreInterval = oneData.ShieldRestoreInterval;

            Rigidbody2D rig = newPrefab.GetComponent <Rigidbody2D>();
            rig.mass = oneData.Mass;

            PrefabUtility.ReplacePrefab(newPrefab, prefab,
                                        ReplacePrefabOptions.Default);
            MonoBehaviour.DestroyImmediate(newPrefab);
        }
        // Debug.Log("Finish updating data of Hero !!!");

        // Debug.Log("Start updating data of Enemy ...");
        List <GDEEnemyData> allEnemyData = GDEDataManager.GetAllItems <GDEEnemyData>();

        foreach (GDEEnemyData oneData in allEnemyData)
        {
            // get prefab
            string     fullPath = "Assets/Resources/" + oneData.PrefabPath + ".prefab";
            GameObject prefab   = AssetDatabase.LoadAssetAtPath(
                fullPath,
                typeof(GameObject)) as GameObject;
            GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab)
                                   as GameObject;

            Debug.Assert(prefab != null, "!!! Check Path <" + fullPath + "> !!!");

            Enemy enemy = newPrefab.GetComponent <Enemy>();
            enemy.m_MaxHP           = oneData.MaxHP;
            enemy.m_MoveVec         = oneData.MoveVec;
            enemy.m_AlertRange      = oneData.AlertRange;
            enemy.m_AtkRange        = oneData.AtkRange;
            enemy.m_AtkInterval     = oneData.AtkInterval;
            enemy.m_HurtProtectTime = oneData.HurtProtect;

            Rigidbody2D rig = newPrefab.GetComponent <Rigidbody2D>();
            rig.mass = oneData.Mass;


            PrefabUtility.ReplacePrefab(newPrefab, prefab,
                                        ReplacePrefabOptions.Default);
            MonoBehaviour.DestroyImmediate(newPrefab);
        }
        // Debug.Log("Finish updating data of Enemy !!!");

        // Debug.Log("Start updating data of Weapon ...");
        List <GDEWeaponData> allWeaponData = GDEDataManager.GetAllItems <GDEWeaponData>();

        foreach (GDEWeaponData oneData in allWeaponData)
        {
            // get prefab
            string     fullPath = "Assets/Resources/" + oneData.PrefabPath + ".prefab";
            GameObject prefab   = AssetDatabase.LoadAssetAtPath(
                fullPath,
                typeof(GameObject)) as GameObject;
            GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab)
                                   as GameObject;

            Debug.Assert(prefab != null, "!!! Check Path <" + fullPath + "> !!!");

            Weapon weapon = newPrefab.GetComponent <Weapon>();
            weapon.m_WeaponID      = (WeaponID)oneData.ID;
            weapon.m_MaxBullet     = oneData.MagazineSize;
            weapon.m_ConsumePerHit = oneData.ConsumePerHit;
            weapon.m_AtkInterval   = oneData.AtkInterval;
            weapon.m_ChargeTime    = oneData.ChargeTime;
            weapon.m_ReloadTime    = oneData.ReloadTime;
            WeaponOperateType opaType = (WeaponOperateType)oneData.OpaType.ID;
            weapon.m_OpaType       = opaType;
            weapon.m_SpineSkinName = oneData.SkinName;
            weapon.m_AniType       = (WeaponAniType)oneData.AniType.ID;
            weapon.m_AlertRange    = oneData.AlertRange;

            string dmgName = weapon.m_Dmg.name;
            fullPath = "Assets/Resources/Attack/" + dmgName + ".prefab";
            GameObject dmgPrefab = AssetDatabase.LoadAssetAtPath(
                fullPath,
                typeof(GameObject)) as GameObject;
            GameObject newDmgPrefab = PrefabUtility.InstantiatePrefab(dmgPrefab)
                                      as GameObject;
            Debug.Assert(dmgPrefab != null, "!!! Check Path <" + fullPath + "> !!!");

            Damage dmg = newDmgPrefab.GetComponent <Damage>();
            dmg.m_DamageVal = oneData.DamageVal;
            dmg.m_Thrust    = oneData.Thrust;
            PrefabUtility.ReplacePrefab(newDmgPrefab, dmgPrefab,
                                        ReplacePrefabOptions.Default);
            MonoBehaviour.DestroyImmediate(newDmgPrefab);


            PrefabUtility.ReplacePrefab(newPrefab, prefab,
                                        ReplacePrefabOptions.Default);
            MonoBehaviour.DestroyImmediate(newPrefab);
        }
        // Debug.Log("Finish updating data of Weapon !!!");


        AssetDatabase.SaveAssets();
        EditorUtility.DisplayDialog("成功", "UpdateDataFromGDE 完成!", "确定");
    }
コード例 #9
0
    void Start()
    {
        SceneHeader.text      = ReadDataSceneStrings.HeaderLbl;
        SceneDescription.text = ReadDataSceneStrings.DescriptionLbl;

        // Initialize GDE
        if (!GDEDataManager.Init("read_scene_data"))
        {
            Status.text = ReadDataSceneStrings.StatusErrorInitiliazing;
            return;
        }

        data = new GDEReadSceneData(GDEReadSceneItemKeys.ReadScene_test_data);
        if (data == null)
        {
            Status.text = ReadDataSceneStrings.StatusErrorLoadingData;
            return;
        }

        try
        {
            // Bool
            BoolField.text  = ReadDataSceneStrings.BoolFieldLbl + " ";
            BoolField.text += data.bool_field;

            // Bool List
            BoolListField.text = ReadDataSceneStrings.BoolListFieldLbl + " ";
            foreach (bool boolVal in data.bool_list_field)
            {
                BoolListField.text += string.Format("{0} ", boolVal);
            }

            // Int
            IntField.text  = ReadDataSceneStrings.IntFieldLbl + " ";
            IntField.text += data.int_field;

            // Int List
            IntListField.text = ReadDataSceneStrings.IntListFieldLbl + " ";
            foreach (int intVal in data.int_list_field)
            {
                IntListField.text += string.Format("{0} ", intVal);
            }

            // Float
            FloatField.text  = ReadDataSceneStrings.FloatFieldLbl + " ";
            FloatField.text += data.float_field;

            // Float List
            FloatListField.text = ReadDataSceneStrings.FloatListFieldLbl + " ";
            foreach (float floatVal in data.float_list_field)
            {
                FloatListField.text += string.Format("{0} ", floatVal);
            }

            // String
            StringField.text  = ReadDataSceneStrings.StringFieldLbl + " ";
            StringField.text += data.string_field;

            // String List
            StringListField.text = ReadDataSceneStrings.StringListFieldLbl + " ";
            foreach (string stringVal in data.string_list_field)
            {
                StringListField.text += string.Format("{0} ", stringVal);
            }

            // Vector2
            Vector2Field.text  = ReadDataSceneStrings.Vec2FieldLbl + " ";
            Vector2Field.text += string.Format("({0}, {1})", data.vector2_field.x, data.vector2_field.y);

            // Vector2 List
            Vector2LisField.text = ReadDataSceneStrings.Vec2ListFieldLbl + " ";
            foreach (Vector2 vec2Val in data.vector2_list_field)
            {
                Vector2LisField.text += string.Format("({0}, {1}) ", vec2Val.x, vec2Val.y);
            }

            // Vector3
            Vector3Field.text  = ReadDataSceneStrings.Vec3FieldLbl + " ";
            Vector3Field.text += string.Format("({0}, {1}, {2})", data.vector3_field.x, data.vector3_field.y, data.vector3_field.z);

            // Vector3 List
            Vector3ListField.text = ReadDataSceneStrings.Vec3ListFieldLbl + " ";
            foreach (Vector3 vec3Val in data.vector3_list_field)
            {
                Vector3ListField.text += string.Format("({0}, {1}, {2}) ", vec3Val.x, vec3Val.y, vec3Val.z);
            }

            // Vector4
            Vector4Field.text  = ReadDataSceneStrings.Vec4FieldLbl + " ";
            Vector4Field.text += string.Format("({0}, {1}, {2}, {3})", data.vector4_field.x, data.vector4_field.y, data.vector4_field.z, data.vector4_field.w);

            // Vector4 List
            Vector4ListField.text = ReadDataSceneStrings.Vec4ListFieldLbl + " ";
            foreach (Vector4 vec4Val in data.vector4_list_field)
            {
                Vector4ListField.text += string.Format("({0}, {1}, {2}, {3}) ", vec4Val.x, vec4Val.y, vec4Val.z, vec4Val.w);
            }

            // Color
            ColorField.text  = ReadDataSceneStrings.ColorFieldLbl + " ";
            ColorField.text += data.color_field.ToString();

            // Color List
            ColorListField.text = ReadDataSceneStrings.ColorListFieldLbl + " ";
            foreach (Color colVal in data.color_list_field)
            {
                ColorListField.text += string.Format("{0}   ", colVal);
            }

            // Custom
            // See LoadUnityTypes for a Custom field example

            LoadUnityTypes();

            /**
             *
             * The following two methods (GetAllDataBySchema and GetAllKeysBySchema) are part of the old version of the GDE API.
             * They still work, but require a little more code to use.
             *
             **/

            // Get All Data By Schema
            GetAllDataBySchema.text = ReadDataSceneStrings.GetAllBySchemaLbl + Environment.NewLine;
            Dictionary <string, object> allDataByCustomSchema;
            GDEDataManager.GetAllDataBySchema("ReadSceneCustom", out allDataByCustomSchema);
            foreach (KeyValuePair <string, object> pair in allDataByCustomSchema)
            {
                string description;
                Dictionary <string, object> customData = pair.Value as Dictionary <string, object>;
                customData.TryGetString("description", out description);
                GetAllDataBySchema.text += string.Format("     {0}{1}", description, Environment.NewLine);
            }

            // Get All Keys By Schema
            GetAllKeysBySchema.text = ReadDataSceneStrings.GetAllKeysBySchemaLbl + " ";
            List <string> customKeys;
            GDEDataManager.GetAllDataKeysBySchema("ReadSceneCustom", out customKeys);
            foreach (string key in customKeys)
            {
                GetAllKeysBySchema.text += string.Format("{0} ", key);
            }

            Status.text = ReadDataSceneStrings.StatusSuccess;
        }
        catch (Exception ex)
        {
            Status.text = ReadDataSceneStrings.StatusError;
            Debug.LogError(ex);
        }
    }
コード例 #10
0
    public void Start()
    {
        GDEDataManager.Init("gde_data");

        object vfactionList = factionPicked.ToString();

        factionList = (GDEfactionData)vfactionList;

        if (useCustomCaption == false)
        {
            switch (captionType)
            {
            case CaptionType.factionHomeCity:
                if (factionList.factionType == "cult" || factionList.factionType == "religious")
                {
                    caption = "Holy City of " + factionList.religion.fullName;
                    break;
                }
                else if (factionList.factionType == "neutral")
                {
                    caption = factionList.capital + " Trading Hub";
                    break;
                }
                else
                {
                    caption = factionList.capital.fullName;
                    break;
                }

            case CaptionType.factionLeader:
                caption = factionList.leaderTitle;
                break;

            case CaptionType.factionMotto:
                caption = factionList.fullName + Environment.NewLine + "<i><size=8>" + factionList.motto + "</size></i>";
                break;

            case CaptionType.factionName:
                caption = factionList.fullName;
                break;

            case CaptionType.godName:
                if (factionList.factionType == "cult")
                {
                    caption = "True Followers of " + factionList.religion.godName;
                    break;
                }
                else if (factionList.factionType == "military")
                {
                    caption = "Swords of " + factionList.religion.godName;
                    break;
                }
                else
                {
                    caption = "Followers of " + factionList.religion.godName;
                    break;
                }

            case CaptionType.locationName:
            {
                caption = factionList.capital.fullName;
                break;
            }

            case CaptionType.religionName:
                if (factionList.religion.fullName == "atheist")
                {
                    caption = "All beliefs are welcome";
                }
                else
                {
                    caption = "Followers of " + factionList.religion.godName + " welcome";
                }
                break;

            default:
                break;
            }
        }
    }
コード例 #11
0
#pragma warning disable CS0618 // Type or member is obsolete
		/// <summary>
		/// Tries to set the value for any Field.
		/// </summary>
		/// <param name="fieldValue">Ensure that the object is of the same type as the given fieldType.</param>
		public static void SetFieldValue(string itemName, string fieldName,
										 object fieldValue, GDEFieldType fieldType = GDEFieldType.None)
		{
			if(fieldValue == null)
			{
				UnityEngine.Debug.LogError("Field Value is null while trying to set Field Value for "
											+ fieldName + " on " + itemName + "!");
				return;
			}

			GDEFieldType selFieldType = ParseFieldValueTypeIfNone(fieldValue, fieldType);

			switch(fieldValue.GetType().ToString().Replace("System.", ""))
			{
				case "Int16":
				case "Int64":
					fieldValue = Convert.ToInt32(fieldValue);
					break;
			}

			try
			{
				switch(selFieldType)
				{
					case GDEFieldType.Bool:
						GDEDataManager.SetBool(itemName, fieldName, (bool)fieldValue);
						break;
					case GDEFieldType.BoolList:
						GDEDataManager.SetBoolList(itemName, fieldName, (List<bool>)fieldValue);
						break;
					case GDEFieldType.BoolTwoDList:
						GDEDataManager.SetBoolTwoDList(itemName, fieldName, (List<List<bool>>)fieldValue);
						break;
					case GDEFieldType.Int:
						GDEDataManager.SetInt(itemName, fieldName, (int)fieldValue);
						break;
					case GDEFieldType.IntList:
						GDEDataManager.SetIntList(itemName, fieldName, (List<int>)fieldValue);
						break;
					case GDEFieldType.IntTwoDList:
						GDEDataManager.SetIntTwoDList(itemName, fieldName, (List<List<int>>)fieldValue);
						break;
					case GDEFieldType.Float:
						GDEDataManager.SetFloat(itemName, fieldName, (float)fieldValue);
						break;
					case GDEFieldType.FloatList:
						GDEDataManager.SetFloatList(itemName, fieldName, (List<float>)fieldValue);
						break;
					case GDEFieldType.FloatTwoDList:
						GDEDataManager.SetFloatTwoDList(itemName, fieldName, (List<List<float>>)fieldValue);
						break;
					case GDEFieldType.String:
						GDEDataManager.SetString(itemName, fieldName, (string)fieldValue);
						break;
					case GDEFieldType.StringList:
						GDEDataManager.SetStringList(itemName, fieldName, (List<string>)fieldValue);
						break;
					case GDEFieldType.StringTwoDList:
						GDEDataManager.SetStringTwoDList(itemName, fieldName, (List<List<string>>)fieldValue);
						break;
					case GDEFieldType.Vector2:
						GDEDataManager.SetVector2(itemName, fieldName, (Vector2)fieldValue);
						break;
					case GDEFieldType.Vector2List:
						GDEDataManager.SetVector2List(itemName, fieldName, (List<Vector2>)fieldValue);
						break;
					case GDEFieldType.Vector2TwoDList:
						GDEDataManager.SetVector2TwoDList(itemName, fieldName, (List<List<Vector2>>)fieldValue);
						break;
					case GDEFieldType.Vector3:
						GDEDataManager.SetVector3(itemName, fieldName, (Vector3)fieldValue);
						break;
					case GDEFieldType.Vector3List:
						GDEDataManager.SetVector3List(itemName, fieldName, (List<Vector3>)fieldValue);
						break;
					case GDEFieldType.Vector3TwoDList:
						GDEDataManager.SetVector3TwoDList(itemName, fieldName, (List<List<Vector3>>)fieldValue);
						break;
					case GDEFieldType.Vector4:
						GDEDataManager.SetVector4(itemName, fieldName, (Vector4)fieldValue);
						break;
					case GDEFieldType.Vector4List:
						GDEDataManager.SetVector4List(itemName, fieldName, (List<Vector4>)fieldValue);
						break;
					case GDEFieldType.Vector4TwoDList:
						GDEDataManager.SetVector4TwoDList(itemName, fieldName, (List<List<Vector4>>)fieldValue);
						break;
					case GDEFieldType.Color:
						GDEDataManager.SetColor(itemName, fieldName, (Color)fieldValue);
						break;
					case GDEFieldType.ColorList:
						GDEDataManager.SetColorList(itemName, fieldName, (List<Color>)fieldValue);
						break;
					case GDEFieldType.ColorTwoDList:
						GDEDataManager.SetColorTwoDList(itemName, fieldName, (List<List<Color>>)fieldValue);
						break;
					case GDEFieldType.GameObject:
						GDEDataManager.SetGameObject(itemName, fieldName, (GameObject)fieldValue);
						break;
					case GDEFieldType.GameObjectList:
						GDEDataManager.SetGameObjectList(itemName, fieldName, (List<GameObject>)fieldValue);
						break;
					case GDEFieldType.GameObjectTwoDList:
						GDEDataManager.SetGameObjectTwoDList(itemName, fieldName, (List<List<GameObject>>)fieldValue);
						break;
					case GDEFieldType.Texture2D:
						GDEDataManager.SetTexture2D(itemName, fieldName, (Texture2D)fieldValue);
						break;
					case GDEFieldType.Texture2DList:
						GDEDataManager.SetTexture2DList(itemName, fieldName, (List<Texture2D>)fieldValue);
						break;
					case GDEFieldType.Texture2DTwoDList:
						GDEDataManager.SetTexture2DTwoDList(itemName, fieldName, (List<List<Texture2D>>)fieldValue);
						break;
					case GDEFieldType.Material:
						GDEDataManager.SetMaterial(itemName, fieldName, (Material)fieldValue);
						break;
					case GDEFieldType.MaterialList:
						GDEDataManager.SetMaterialList(itemName, fieldName, (List<Material>)fieldValue);
						break;
					case GDEFieldType.MaterialTwoDList:
						GDEDataManager.SetMaterialTwoDList(itemName, fieldName, (List<List<Material>>)fieldValue);
						break;
					case GDEFieldType.AudioClip:
						GDEDataManager.SetAudioClip(itemName, fieldName, (AudioClip)fieldValue);
						break;
					case GDEFieldType.AudioClipList:
						GDEDataManager.SetAudioClipList(itemName, fieldName, (List<AudioClip>)fieldValue);
						break;
					case GDEFieldType.AudioClipTwoDList:
						GDEDataManager.SetAudioClipTwoDList(itemName, fieldName, (List<List<AudioClip>>)fieldValue);
						break;
				}
			} catch(UnityException ex)
			{
				UnityEngine.Debug.LogError(string.Format(GDMConstants.ErrorSettingValue, GDMConstants.StringType, itemName, fieldName));
				UnityEngine.Debug.LogError(ex.ToString());
			}
		}
コード例 #12
0
		public static void Save()
		{
			GDEDataManager.Save();
		}
コード例 #13
0
 private void InitData()
 {
     GDEDataManager.Init("gde_data");
 }
コード例 #14
0
    void OnGUI()
    {
        skin = GUI.skin;
        size = Vector2.zero;
        if (content == null)
        {
            content = new GUIContent();
        }

        ResetToTop();

        DrawLabel(SetDataSceneStrings.HeaderLbl);
        DrawLabel(SetDataSceneStrings.DescriptionLbl);
        NewLine();

                #if !UNITY_WEBPLAYER
        if (DrawButton(SetDataSceneStrings.SaveAllBtn))
        {
            GDEDataManager.Save();
        }
        if (DrawButton(SetDataSceneStrings.CreateRandomBtn))
        {
            var newItem = new GDESetCustomData(Guid.NewGuid().ToString().Replace("-", ""));
            newItem.bool_field    = Convert.ToBoolean(Random.Range(0, 1));
            newItem.int_field     = Random.Range(-100, 100);
            newItem.float_field   = Random.Range(-100f, 100f);
            newItem.description   = "My ID is: " + newItem.Key;
            newItem.vector2_field = new Vector2(Random.Range(0f, 1f), Random.Range(0f, 1f));
            newItem.vector3_field = new Vector3(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
            newItem.color_field   = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
        }
        if (DrawButton(SetDataSceneStrings.ReloadAllBtn))
        {
            LoadItems();
        }
                #endif

        if (DrawButton(SetDataSceneStrings.ResetAllBtn))
        {
            singleData.ResetAll();
            listData.ResetAll();
            twoDListData.ResetAll();

                        #if !UNITY_WEBPLAYER
            GDEDataManager.ClearSaved();
                        #endif
        }

        NewLine(2);

        DrawLabel(SetDataSceneStrings.SingleOrListLbl);
        NewLine();
        if (DrawButton(SetDataSceneStrings.SingleBtn))
        {
            selectedType = DataType.Single;
        }
        if (DrawButton(SetDataSceneStrings.ListBtn))
        {
            selectedType = DataType.List;
        }

        NewLine(2);

        DrawLabel(SetDataSceneStrings.TwoDListLbl);
        NewLine();
        if (DrawButton("Bool 2D"))
        {
            selectedType = DataType.Bool2D;
        }
        if (DrawButton("Int 2D"))
        {
            selectedType = DataType.Int2D;
        }
        if (DrawButton("Float 2D"))
        {
            selectedType = DataType.Float2D;
        }
        if (DrawButton("String 2D"))
        {
            selectedType = DataType.String2D;
        }
        if (DrawButton("Vec2 2D"))
        {
            selectedType = DataType.Vec2_2D;
        }
        if (DrawButton("Vec3 2D"))
        {
            selectedType = DataType.Vec3_2D;
        }
        if (DrawButton("Vec4 2D"))
        {
            selectedType = DataType.Vec4_2D;
        }
        if (DrawButton("Color 2D"))
        {
            selectedType = DataType.Color_2D;
        }
        if (DrawButton("Custom 2D"))
        {
            selectedType = DataType.Custom_2D;
        }

        NewLine(2);

        DrawLabel(SetDataSceneStrings.SetDataLbl);
        NewLine(3);
        if (selectedType.Equals(DataType.Single))
        {
            DrawSingleData();
        }
        else if (selectedType.Equals(DataType.List))
        {
            DrawListData();
        }
        else if (selectedType.Equals(DataType.Bool2D))
        {
            DrawBoolData();
        }
        else if (selectedType.Equals(DataType.Int2D))
        {
            DrawIntData();
        }
        else if (selectedType.Equals(DataType.Float2D))
        {
            DrawFloatData();
        }
        else if (selectedType.Equals(DataType.String2D))
        {
            DrawStringData();
        }
        else if (selectedType.Equals(DataType.Vec2_2D))
        {
            DrawVector2Data();
        }
        else if (selectedType.Equals(DataType.Vec3_2D))
        {
            DrawVector3Data();
        }
        else if (selectedType.Equals(DataType.Vec4_2D))
        {
            DrawVector4Data();
        }
        else if (selectedType.Equals(DataType.Color_2D))
        {
            DrawColorData();
        }
        else if (selectedType.Equals(DataType.Custom_2D))
        {
            DrawCustomData();
        }
    }
コード例 #15
0
 public override List <GDEItemData> GetList()
 {
     GDEDataManager.Init("gde_data");
     list_data = GDEDataManager.GetAllItems <GDEItemData>();
     return(list_data);
 }
コード例 #16
0
ファイル: ReadDataScene.cs プロジェクト: tuita520/RL_CardGame
    void Start()
    {
        // Initialize GDE
        // This will load the data file with this name. Do not specify the extension.
        // You can also pass a TextAsset instead of a string.
        if (!GDEDataManager.Init("read_scene_data"))
        {
            Status.text = ReadDataSceneStrings.StatusErrorInitiliazing;
            return;
        }

        // Here is how you load an item using the generated data class.
        // The constructor will load the item with ID "test_data" of the ReadScene schema.
        // The GDEReadSceneItemKeys class is also generated. It contains fields for every
        // item ID so that you can easily access item data without the need for hard coded
        // strings.
        gde_data = new GDEReadSceneData(GDEReadSceneItemKeys.ReadScene_test_data);
        if (gde_data == null)
        {
            Status.text = ReadDataSceneStrings.StatusErrorLoadingData;
            return;
        }

        try
        {
            // The following shows how each field in the ReadScene schema is accessed.
            // Each field in the schema will have a field of the correct type in the
            // generated class.
            // Lists are generic List<>, 2D lists are also generic List<List<>>
            // You can modify these fields at will. To save your modifications to
            // persistent data, call GDEDataManager.Save(); when it is convenient.

            // Bool
            BoolField.text  = ReadDataSceneStrings.BoolFieldLbl + " ";
            BoolField.text += gde_data.bool_field;

            // Bool List
            BoolListField.text = ReadDataSceneStrings.BoolListFieldLbl + " ";
            foreach (bool boolVal in gde_data.bool_list_field)
            {
                BoolListField.text += string.Format("{0} ", boolVal);
            }

            // Int
            IntField.text  = ReadDataSceneStrings.IntFieldLbl + " ";
            IntField.text += gde_data.int_field;

            // Int List
            IntListField.text = ReadDataSceneStrings.IntListFieldLbl + " ";
            foreach (int intVal in gde_data.int_list_field)
            {
                IntListField.text += string.Format("{0} ", intVal);
            }

            // Float
            FloatField.text  = ReadDataSceneStrings.FloatFieldLbl + " ";
            FloatField.text += gde_data.float_field;

            // Float List
            FloatListField.text = ReadDataSceneStrings.FloatListFieldLbl + " ";
            foreach (float floatVal in gde_data.float_list_field)
            {
                FloatListField.text += string.Format("{0} ", floatVal);
            }

            // String
            StringField.text  = ReadDataSceneStrings.StringFieldLbl + " ";
            StringField.text += gde_data.string_field;

            // String List
            StringListField.text = ReadDataSceneStrings.StringListFieldLbl + " ";
            foreach (string stringVal in gde_data.string_list_field)
            {
                StringListField.text += string.Format("{0} ", stringVal);
            }

            // Vector2
            Vector2Field.text  = ReadDataSceneStrings.Vec2FieldLbl + " ";
            Vector2Field.text += string.Format("({0}, {1})", gde_data.vector2_field.x, gde_data.vector2_field.y);

            // Vector2 List
            Vector2LisField.text = ReadDataSceneStrings.Vec2ListFieldLbl + " ";
            foreach (Vector2 vec2Val in gde_data.vector2_list_field)
            {
                Vector2LisField.text += string.Format("({0}, {1}) ", vec2Val.x, vec2Val.y);
            }

            // Vector3
            Vector3Field.text  = ReadDataSceneStrings.Vec3FieldLbl + " ";
            Vector3Field.text += string.Format("({0}, {1}, {2})", gde_data.vector3_field.x, gde_data.vector3_field.y, gde_data.vector3_field.z);

            // Vector3 List
            Vector3ListField.text = ReadDataSceneStrings.Vec3ListFieldLbl + " ";
            foreach (Vector3 vec3Val in gde_data.vector3_list_field)
            {
                Vector3ListField.text += string.Format("({0}, {1}, {2}) ", vec3Val.x, vec3Val.y, vec3Val.z);
            }

            // Vector4
            Vector4Field.text  = ReadDataSceneStrings.Vec4FieldLbl + " ";
            Vector4Field.text += string.Format("({0}, {1}, {2}, {3})", gde_data.vector4_field.x, gde_data.vector4_field.y, gde_data.vector4_field.z, gde_data.vector4_field.w);

            // Vector4 List
            Vector4ListField.text = ReadDataSceneStrings.Vec4ListFieldLbl + " ";
            foreach (Vector4 vec4Val in gde_data.vector4_list_field)
            {
                Vector4ListField.text += string.Format("({0}, {1}, {2}, {3}) ", vec4Val.x, vec4Val.y, vec4Val.z, vec4Val.w);
            }

            // Color
            ColorField.text  = ReadDataSceneStrings.ColorFieldLbl + " ";
            ColorField.text += gde_data.color_field.ToString();

            // Color List
            ColorListField.text = ReadDataSceneStrings.ColorListFieldLbl + " ";
            foreach (Color colVal in gde_data.color_list_field)
            {
                ColorListField.text += string.Format("{0}   ", colVal);
            }

            // Custom
            // See LoadUnityTypes for a Custom field example

            LoadUnityTypes();

            // There is an updated generic method that will return all items
            // of a particular schema. It looks like this:
            // List<GDEReadSceneData> all = GDEDataManager.GetAllItems<GDEReadSceneData>();
            // Specify the data class corresponding to the schema whose items you
            // want to load all at once


            /**
             *
             * The following two methods (GetAllDataBySchema and GetAllKeysBySchema) are part of the old version of the GDE API.
             * They still work, but require a little more code to use.
             *
             **/

            // Get All Data By Schema
            GetAllDataBySchema.text = ReadDataSceneStrings.GetAllBySchemaLbl + Environment.NewLine;
            Dictionary <string, object> allDataByCustomSchema;
            GDEDataManager.GetAllDataBySchema("ReadSceneCustom", out allDataByCustomSchema);
            foreach (KeyValuePair <string, object> pair in allDataByCustomSchema)
            {
                string description;
                Dictionary <string, object> customData = pair.Value as Dictionary <string, object>;
                customData.TryGetString("description", out description);
                GetAllDataBySchema.text += string.Format("     {0}{1}", description, Environment.NewLine);
            }

            // Get All Keys By Schema
            GetAllKeysBySchema.text = ReadDataSceneStrings.GetAllKeysBySchemaLbl + " ";
            List <string> customKeys;
            GDEDataManager.GetAllDataKeysBySchema("ReadSceneCustom", out customKeys);
            foreach (string key in customKeys)
            {
                GetAllKeysBySchema.text += string.Format("{0} ", key);
            }

            Status.text = ReadDataSceneStrings.StatusSuccess;
        }
        catch (Exception ex)
        {
            Status.text = ReadDataSceneStrings.StatusError;
            Debug.LogError(ex);
        }
    }