Skip to content

Commit

Permalink
Added serialization tagging for more objects.
Browse files Browse the repository at this point in the history
Using ComponentReference very messily for now, just to get things started.
This will probably need to be replaced with a reference class per type, where the YAML just has fileID for all of them.
Still need to write code to map the IDs to object references post-deserialization.
  • Loading branch information
bobsummerwill committed Oct 1, 2014
1 parent ccb1b19 commit 1d8ef29
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
13 changes: 12 additions & 1 deletion Source/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// Copyright (c) 2014 Kitsilano Software Inc (http://kitsilanosoftware.com)
//------------------------------------------------------------------------------

using YamlDotNet.Serialization;

namespace UnityEngine
{
public class Component : Object
Expand Down Expand Up @@ -75,7 +77,16 @@ public T GetComponent<T>()
// public Collider collider { get; }
// public Collider2D collider2D { get; }
// public ConstantForce constantForce { get; }
public GameObject gameObject { get; set; }

[YamlAlias("m_PrefabParentObject")]
public ComponentReference prefabParentObject { get; set; }

[YamlAlias("m_PrefabInternal")]
public ComponentReference prefabInternal { get; set; }

[YamlAlias("m_GameObject")]
public ComponentReference gameObject { get; set; }

// public GUIElement guiElement { get; }
public GUIText guiText { get; set; }
// public GUITexture guiTexture { get; }
Expand Down
18 changes: 18 additions & 0 deletions Source/GameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@
// Copyright (c) 2014 Kitsilano Software Inc (http://kitsilanosoftware.com)
//------------------------------------------------------------------------------

using System.Collections.Generic;
using YamlDotNet.Serialization;

namespace UnityEngine
{
public class ComponentReference
{
public int fileID;
}

public class ComponentList
{
public Dictionary<int, int> dictionary = new Dictionary<int, int>();
}


public sealed class GameObject : Object
{
// public GameObject (string name);
Expand Down Expand Up @@ -88,6 +100,9 @@ public void SetActive(bool value)
[YamlAlias("m_IsActive")]
public bool active { get; set; }

[YamlAlias("m_Component")]
public ComponentList componentReferences { get; set; }

// public bool activeInHierarchy { get; }
public bool activeSelf { get; set; }
// public Animation animation { get; }
Expand All @@ -101,6 +116,9 @@ public void SetActive(bool value)
public GUIText guiText;
public GUITexture guiTexture;
// public HingeJoint hingeJoint { get; }

[YamlAlias("m_Icon")]
public ComponentReference icon { get; set; }

// Not a direct mapping.
// [YamlAlias("m_StaticEditorFlags")]
Expand Down
3 changes: 2 additions & 1 deletion Source/LightmapSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class LightmapSettings : Object
[YamlAlias("m_UseDualLightmapsInForward")]
public /* static */ bool useDualLightmapsInForward { get; set; }

// public static LightProbes lightProbes { get; set; }
[YamlAlias("m_LightProbes")]
public ComponentReference lightProbes { get; set; }
}
}
11 changes: 8 additions & 3 deletions Source/RenderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ public class RenderSettings : Object
[YamlAlias("m_HaloStrength")]
public /* static */ float haloStrength { get; set; }

// TODO: fileID mapping.
// [YamlAlias("m_SkyboxMaterial")]
// public /* static */ Material skybox { get; set; }
[YamlAlias("m_SkyboxMaterial")]
public ComponentReference skybox { get; set; }

[YamlAlias("m_HaloTexture")]
public ComponentReference haloTexture { get; set; }

[YamlAlias("m_SpotCookie")]
public ComponentReference spotCookie { get; set; }
}
}
7 changes: 5 additions & 2 deletions Source/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Transform Find(string name)
// public Vector3 forward { get; set; }
// public bool hasChanged { get; set; }
// public Vector3 localEulerAngles { get; set; }

[YamlAlias("m_LocalPosition")]
public Vector3 localPosition { get; set; }

Expand All @@ -73,7 +73,10 @@ public Transform Find(string name)

[YamlAlias("m_LocalScale")]
public Vector3 localScale { get; set; }


[YamlAlias("m_Children")]
public ComponentReference[] children { get; set; }

// public Matrix4x4 localToWorldMatrix { get; }
// public Vector3 lossyScale { get; }
public Transform parent { get; set; }
Expand Down

0 comments on commit 1d8ef29

Please sign in to comment.