예제 #1
0
    public override IEnumerable <object> Save(Component target)
    {
        SaveGameManager.AssetReference assetId = SaveGameManager.Instance.GetAssetId(target);
        if (assetId.index != -1)
        {
            return(new object[]
            {
                null,
                true,
                target.GetType().FullName,
                assetId
            });
        }
        int num = target.gameObject.GetComponents(target.GetType()).FindIndex((Component c) => c == target);

        if (UniqueIdentifier.GetByName(target.gameObject.GetId()) != null)
        {
            return(new object[]
            {
                target.gameObject.GetId(),
                true,
                target.GetType().FullName,
                string.Empty,
                num
            });
        }
        return(new object[]
        {
            target.gameObject.GetId(),
            false,
            target.GetType().FullName,
            string.Empty,
            num
        });
    }
 public override IEnumerable <object> Save(GameObject target)
 {
     SaveGameManager.AssetReference assetId = SaveGameManager.Instance.GetAssetId(target);
     if (assetId.index != -1)
     {
         return(new object[]
         {
             0,
             true,
             null,
             assetId
         });
     }
     return(new object[]
     {
         target.GetId(),
         UniqueIdentifier.GetByName(target.gameObject.GetId()) != null
     });
 }
예제 #3
0
	public override IEnumerable<object> Save(object target)
	{
		SaveGameManager.AssetReference assetId = SaveGameManager.Instance.GetAssetId(target as UnityEngine.Object);
		if (assetId.index == -1)
		{
			byte[] array = UnitySerializer.SerializeForDeserializeInto(target);
			return new object[]
			{
				true,
				target.GetType().FullName,
				array
			};
		}
		return new object[]
		{
			false,
			assetId
		};
	}
예제 #4
0
    public object GetAsset(SaveGameManager.AssetReference id)
    {
        if (id.index == -1)
        {
            return(null);
        }
        object result;

        try
        {
            Type typeEx = UnitySerializer.GetTypeEx(id.type);
            Index <string, List <UnityEngine.Object> > index;
            if (!this.assetReferences.TryGetValue(typeEx, out index))
            {
                index = (this.assetReferences[typeEx] = new Index <string, List <UnityEngine.Object> >());
                IEnumerable <UnityEngine.Object> enumerable = Resources.FindObjectsOfTypeAll(typeEx).Except(UnityEngine.Object.FindObjectsOfType(typeEx));
                foreach (UnityEngine.Object current in enumerable)
                {
                    index[current.name].Add(current);
                }
            }
            List <UnityEngine.Object> list;
            if (!index.TryGetValue(id.name, out list))
            {
                result = null;
            }
            else if (id.index >= list.Count)
            {
                result = null;
            }
            else
            {
                result = list[id.index];
            }
        }
        catch
        {
            result = null;
        }
        return(result);
    }