/// <summary>
    /// Assumption: component represents the same sComponent from source object
    /// </summary>
    static void VerifyComponent(Component component, SerializableComponent sComponent)
    {
        //Debug.Log("gil - ComponentAsText::VerifyComponent - testing " + component.GetType().Name + " with SerializableComponent " + sComponent.componentName);

        for (int i = 0; i < componentsDeserializableReferences.Count; i++)
        {
            if (sComponent.componentId == componentsDeserializableReferences[i].componentReferenceId)
            {
                Type           type   = componentsToSetComponent[i].GetType();
                BindingFlags   flags  = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Default | BindingFlags.DeclaredOnly;
                PropertyInfo[] pinfos = type.GetProperties(flags);
                foreach (var pinfo in pinfos)
                {
                    if (pinfo.CanWrite && pinfo.Name == componentPropertyNames[i])
                    {
                        try {
                            pinfo.SetValue(componentsToSetComponent[i], component, null);
                        } catch {}
                    }
                }

                FieldInfo[] finfos = type.GetFields(flags);
                foreach (var finfo in finfos)
                {
                    if (finfo.Name == componentPropertyNames[i])
                    {
                        try {
                            finfo.SetValue(componentsToSetComponent[i], component);
                        } catch {}
                    }
                }
            }
        }
    }
 static void VerifyReferencedComponents(Component component, SerializableComponent sComponent)
 {
     for (int i = 0; i < referencedComponents.Count; i++)
     {
         if (component == referencedComponents[i])
         {
             componentsSerializableReferences[i].componentReferenceId = sComponent.componentId;
             componentReferenceProperties[i].propertyValue            = componentsSerializableReferences[i].GetString();
         }
     }
 }
    static void PasteTransform()
    {
        Transform target = Selection.activeTransform;

        if (target != null)
        {
            SerializableComponent sComponent = SerializableComponent.LoadFromText(EditorGUIUtility.systemCopyBuffer);
            if (sComponent != null)
            {
                sComponent.ApplySerializedDataTo(target);
            }
        }
    }
    static void CopyTransform()
    {
        Transform target = Selection.activeTransform;

        if (target != null)
        {
            SerializableComponent sComponent = GetSerializableComponent(target);
            if (sComponent != null)
            {
                EditorGUIUtility.systemCopyBuffer = sComponent.GetString();
            }
        }
    }
示例#5
0
        protected override void Update()
        {
            using (Property()) {
                Label();
                Default(field => field.Component);

                var behaviour = GetBehaviour();

                var typeName  = GetValue(field => field.Component.TypeName);
                var index     = GetValue(field => field.Component.Index);
                var component = SerializableComponent.Get(behaviour, typeName, index);

                var fields = component.GetType()
                             .GetProperties()
                             .Where(each => each.GetGetMethod() != null)
                             .OrderBy(each => each.Name)
                             .ToDictionary(each => each.Name, each => each.Name);

                Next();
                UI.Dropdown(fields, property => property.PropertyName);
            }
        }
示例#6
0
        public void Save(SerializableComponent serializable)
        {
            serializable.Name             = Name;
            serializable.Description      = Description;
            serializable.DisplayCategory  = DisplayCategory;
            serializable.Availability     = Availability;
            serializable.ComponentStatsId = StatsId.Id;
            serializable.Faction          = FactionId.Id;
            serializable.Level            = Level.Value;
            serializable.Icon             = IconId;
            serializable.Color            = Helpers.ColorToString(Color);
            serializable.Layout           = Layout.Data;
            serializable.CellType         = CellType == CellType.Empty ? string.Empty : ((char)CellType).ToString();
            serializable.DeviceId         = DeviceId.Id;
            serializable.WeaponId         = WeaponId.Id;
            serializable.AmmunitionId     = AmmunitionId.IsNull ? AmmunitionObsoleteId.Id : AmmunitionId.Id;
            serializable.WeaponSlotType   = WeaponSlotType == WeaponSlotType.Default ? string.Empty : ((char)WeaponSlotType).ToString();
            serializable.DroneBayId       = DroneBayId.Id;
            serializable.DroneId          = DroneId.Id;

            serializable.PossibleModifications = PossibleModification.Select(item => item.Modification.Id).ToArray();
        }
        protected override void Update()
        {
            var source = GetValue(field => field.Source);

            if (source != null)
            {
                using (Property()) {
                    Label();

                    var components = GetComponentDictionary(source);

                    var result = UI.Dropdown(components, field => field.ComponentName);

                    if (result.Index >= 0)
                    {
                        var value = GetValue(field => field.ComponentName);

                        if (value.Contains("|"))
                        {
                            var index = value.Split('|').Last();
                            SetProperty(field => field.Index, index);
                        }
                    }

                    // New scope
                    {
                        var typeName      = GetValue(field => field.ComponentName);
                        var index         = GetValue(field => field.Index);
                        var component     = SerializableComponent.Get(source, typeName, index);
                        var componentType = component.GetType();

                        var dictionary = componentType.GetEvents().ToDictionary(each => each.Name, each => each.Name);

                        LeftGap();
                        UI.Dropdown(dictionary, property => property.EventName);
                    }
                }
            }
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        SerializableComponent serializableComponent = (SerializableComponent)target;

        string Stored = DetectStoredFormat();

        if (Stored == "ERROR")
        {
            EditorGUILayout.HelpBox("Only you can save with a type of stored, static or dynamic mode", MessageType.Error);
        }
        else if (Stored == "Internal ERROR")
        {
            EditorGUILayout.HelpBox("It could not be detected in the way that is going to save", MessageType.Error);
        }

        GUILayout.Label(string.Format("This gameobject is linked with the system stored in {0}", Stored));

        foreach (MonoBehaviour link in serializableComponent.ValidToLinkComponents.ToArray())
        {
            if (link == null)
            {
                serializableComponent.ValidToLinkComponents.Remove(link);
            }
            else
            {
                GUILayout.Label(string.Format("The {0} file is valid and will be saved", link.GetType().Name));
            }
        }

        if (GUILayout.Button("Search again"))
        {
            serializableComponent.DetectComponents();
        }
    }
示例#9
0
    public SerializableGameObject ToSerializableGameObject(GameObject targetObject)
    {
        Component[] allComponents;
        allComponents = targetObject.GetComponents(typeof(Component));

        List <SerializableComponent> serializableComponents = new List <SerializableComponent>();

        foreach (Component comp in allComponents)
        {
            if (comp.GetType() == typeof(Transform))
            {
                continue;
            }

            SerializableComponent sComp           = new SerializableComponent(comp.GetType(), null, null);
            List <string>         propertiesNames = new List <string>();
            List <object>         values          = new List <object>();
            foreach (PropertyInfo pInfo in comp.GetType().GetProperties())
            {
                try {
                    //trying to store the component property data
                    object pValue = pInfo.GetValue(targetObject.GetComponent(comp.GetType()));

                    if (pValue.GetType() == typeof(Vector2))
                    {
                        pValue = new SerializableVector2((Vector2)pValue);
                    }
                    else if (pValue.GetType() == typeof(Vector3))
                    {
                        pValue = new SerializableVector3((Vector3)pValue);
                    }
                    else if (pValue.GetType() == typeof(Quaternion))
                    {
                        pValue = new SerializableQuaternion((Quaternion)pValue);
                    }
                    else if (pValue.GetType() == typeof(Sprite))
                    {
                        pValue = new SerializableSprite((Sprite)pValue);
                    }
                    else if (pValue.GetType() == typeof(Color))
                    {
                        pValue = new SerializableColor((Color)pValue);
                    }
                    else if (pValue.GetType() == typeof(Vector4))
                    {
                        pValue = new SerializableVector4((Vector4)pValue);
                    }
                    else if (pValue.GetType() == typeof(Bounds))
                    {
                        pValue = new SerializableBounds((Bounds)pValue);
                    }
                    else if (pValue.GetType() == typeof(Matrix4x4))
                    {
                        pValue = new Serializable4x4Matrix((Matrix4x4)pValue);
                    }
                    else if (pValue.GetType() == typeof(Vector2[]))
                    {
                        Vector2[]             data    = (Vector2[])pValue;
                        SerializableVector2[] vectors = new SerializableVector2[data.Length];
                        for (int i = 0; i < data.Length; i++)
                        {
                            vectors[i] = new SerializableVector2(data[i]);
                        }
                        pValue = vectors;
                    }
                    else if (pValue.GetType() == typeof(Vector3[]))
                    {
                        Vector3[]             data    = (Vector3[])pValue;
                        SerializableVector3[] vectors = new SerializableVector3[data.Length];
                        for (int i = 0; i < data.Length; i++)
                        {
                            vectors[i] = new SerializableVector3(data[i]);
                        }

                        pValue = vectors;
                    }
                    else if (pValue.GetType() == typeof(RuntimeAnimatorController))
                    {
                        pValue = new SerializableAnimatorController((RuntimeAnimatorController)pValue);
                    }
                    else if (!(pValue.GetType().IsSerializable) || !(pValue.GetType().IsArray&& pValue.GetType().GetElementType().IsSerializable))
                    {
                        continue;
                    }

                    values.Add(pValue);
                    propertiesNames.Add(pInfo.Name);
                } catch (Exception e) {
                    continue;
                }
            }
            sComp.propertiesNames = propertiesNames;


            foreach (object obj in values)
            {
                if (obj.GetType().IsSerializable == false)
                {
                    values.Remove(obj);
                    propertiesNames.Remove(propertiesNames[values.IndexOf(obj)]);
                }
                Debug.Log(".............." + obj.GetType() + "..............");
            }

            sComp.values = values;
            serializableComponents.Add(sComp);
        }

        List <SerializableGameObject> childs = new List <SerializableGameObject>();

        foreach (Transform child in targetObject.transform)
        {
            childs.Add(ToSerializableGameObject(child.gameObject));
        }

        List <float> position = new List <float>();

        position.Add(targetObject.transform.position.x);
        position.Add(targetObject.transform.position.y);
        position.Add(targetObject.transform.position.z);

        List <float> rotation = new List <float>();

        rotation.Add(targetObject.transform.eulerAngles.x);
        rotation.Add(targetObject.transform.eulerAngles.y);
        rotation.Add(targetObject.transform.eulerAngles.z);

        List <float> scale = new List <float>();

        scale.Add(targetObject.transform.localScale.x);
        scale.Add(targetObject.transform.localScale.y);
        scale.Add(targetObject.transform.localScale.z);

        List <List <float> > transformData = new List <List <float> >();

        transformData.Add(position);
        transformData.Add(rotation);
        transformData.Add(scale);

        SerializableGameObject sObject = new SerializableGameObject(targetObject.name, serializableComponents, transformData, childs);

        return(sObject);
    }
示例#10
0
        public Component(SerializableComponent component, Database database)
        {
            ItemId          = new ItemId <Component>(component.Id, component.FileName);
            Name            = component.Name;
            Description     = component.Description;
            DisplayCategory = component.DisplayCategory;
            Availability    = component.Availability;
            FactionId       = database.GetFaction(component.Faction).ItemId;
            Level           = new NumericValue <int>(component.Level, 0, 500);
            Color           = Helpers.ColorFromString(component.Color);
            Layout          = new Layout(component.Layout);
            CellType        = string.IsNullOrEmpty(component.CellType) ? CellType.Empty : (CellType)component.CellType.First();
            IconId          = component.Icon;

            var stats = database.GetComponentStats(component.ComponentStatsId);

            if (stats != null)
            {
                StatsId = stats.ItemId;
            }

            var device = database.GetDevice(component.DeviceId);

            if (device != null)
            {
                DeviceId = device.ItemId;
            }

            var weapon = database.GetWeapon(component.WeaponId);

            if (weapon != null)
            {
                WeaponId = weapon.ItemId;
            }

            WeaponSlotType = string.IsNullOrEmpty(component.WeaponSlotType) ? WeaponSlotType.Default : (WeaponSlotType)component.WeaponSlotType.First();

            AmmunitionId = database.GetAmmunitionId(component.AmmunitionId);
            if (AmmunitionId.IsNull)
            {
                AmmunitionObsoleteId = database.GetAmmunitionObsoleteId(component.AmmunitionId);
            }

            var dronebay = database.GetDroneBay(component.DroneBayId);

            if (dronebay != null)
            {
                DroneBayId = dronebay.ItemId;
            }

            var drone = database.GetShipBuild(component.DroneId);

            if (drone != null)
            {
                DroneId = drone.ItemId;
            }

            if (component.PossibleModifications != null)
            {
                PossibleModification = component.PossibleModifications.Select(item => new ComponentModWrapper {
                    Modification = database.GetComponentModId(item)
                }).ToArray();
            }
            else
            {
                PossibleModification = new ComponentModWrapper[] {}
            };
        }
示例#11
0
        protected override void Update()
        {
            using (Property()) {
                Label();
                Default(field => field.Source);
                Newline();

                var source = GetValue(field => field.Source);

                if (source == null)
                {
                    return;
                }

                var componentType = source.GetType();
                var bindingFlags  = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;

                if (componentType.Is <MonoScript>())
                {
                    componentType = source.As <MonoScript>().GetClass();
                }

                if (componentType.Is <MonoBehaviour>() || componentType.Is <ScriptableObject>())
                {
                    var properties = componentType.GetProperties(bindingFlags)
                                     .Where(each => each.GetGetMethod() != null)
                                     .OrderBy(each => each.Name)
                                     .Cast <MemberInfo>();

                    var fields = componentType.GetFields(bindingFlags)
                                 .OrderBy(each => each.Name)
                                 .Cast <MemberInfo>();

                    var dictionary = fields.Concat(properties).Concat(componentType.GetEvents(bindingFlags)).ToDictionary(each => each.Name, each => each.Name);

                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    UI.Dropdown(dictionary, property => property.MemberName);
                }
                else
                {
                    var gameObject = source as GameObject;

                    if (gameObject.IsPrefab())
                    {
                        return;
                    }

                    var components = GetComponentDictionary(gameObject);
                    var result     = UI.Dropdown(components, field => field.ComponentName);

                    if (result.Index >= 0)
                    {
                        var value = GetValue(field => field.ComponentName);

                        if (value.Contains("|"))
                        {
                            SetProperty(field => field.Index, value.Split('|').Last());
                        }
                    }

                    var typeName            = GetValue(field => field.ComponentName);
                    var index               = GetValue(field => field.Index);
                    var component           = SerializableComponent.Get(gameObject, typeName, index);
                    var chosenComponentType = component.GetType();

                    var properties = chosenComponentType.GetProperties(bindingFlags)
                                     .Where(each => each.GetGetMethod() != null)
                                     .OrderBy(each => each.Name)
                                     .Cast <MemberInfo>();

                    var fields = chosenComponentType.GetFields(bindingFlags)
                                 .OrderBy(each => each.Name)
                                 .Cast <MemberInfo>();

                    var componentDictionary = fields.Concat(properties)
                                              .Concat(chosenComponentType.GetEvents(bindingFlags))
                                              .ToDictionary(each => each.Name, each => each.Name);

                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    LeftGap();
                    UI.Dropdown(componentDictionary, property => property.MemberName);
                }
            }
        }
    static bool isDuplicatedComponent(GameObject gameObject, SerializableGameObject sGObject, SerializableComponent component)
    {
        int numberOfComponents = 0;

        foreach (var copiedComponent in sGObject.components)
        {
            if (copiedComponent.componentName == component.componentName)
            {
                numberOfComponents++;
            }
        }

        return(gameObject.GetComponent(component.componentName) != null && numberOfComponents == 1);
    }
    static SerializableComponent GetSerializableComponent(Component component)
    {
        SerializableComponent sComponent = new SerializableComponent();

        sComponent.componentId   = currentComponentId;
        sComponent.componentName = component.GetType().Name;

        currentComponentId++;

        SerializableComponentProperty sProp;

        Type         type  = component.GetType();
        BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Default | BindingFlags.DeclaredOnly;

        PropertyInfo[] pinfos = type.GetProperties(flags);
        foreach (var pinfo in pinfos)
        {
            if (pinfo.CanWrite)
            {
                // try {
                //     Debug.Log(sComponent.componentName + "." + pinfo.Name + " = " + pinfo.GetValue(copiedComponents[c], null).ToString() +
                //        " [" + pinfo.PropertyType.ToString() + "] ");
                // }
                // catch { } // In case of NotImplementedException being thrown. For some reason specifying that exception didn't seem to catch it, so I didn't catch anything specific.

                try {
                    if (pinfo.PropertyType == typeof(string) ||
                        pinfo.PropertyType == typeof(int) ||
                        pinfo.PropertyType == typeof(float) ||
                        pinfo.PropertyType == typeof(bool))
                    {
                        sProp = new SerializableComponentProperty();
                        sProp.propertyName = pinfo.Name;
                        if (pinfo.PropertyType == typeof(string) && pinfo.GetValue(component, null) == null)
                        {
                            sProp.propertyValue = "";
                        }
                        else
                        {
                            sProp.propertyValue = pinfo.GetValue(component, null).ToString();
                        }

                        if (pinfo.PropertyType == typeof(string))
                        {
                            sProp.propertyType = 0;
                        }
                        else if (pinfo.PropertyType == typeof(int))
                        {
                            sProp.propertyType = 1;
                        }
                        else if (pinfo.PropertyType == typeof(float))
                        {
                            sProp.propertyType = 2;
                        }
                        else if (pinfo.PropertyType == typeof(bool))
                        {
                            sProp.propertyType = 3;
                        }
                        sComponent.properties.Add(sProp);
                    }
                    else if (pinfo.PropertyType == typeof(Vector3))
                    {
                        sProp = new SerializableComponentProperty();
                        sProp.propertyName  = pinfo.Name;
                        sProp.propertyValue = new SerializableVector3((Vector3)pinfo.GetValue(component, null)).GetString();
                        sProp.propertyType  = 4;
                        sComponent.properties.Add(sProp);
                    }
                    else if (pinfo.PropertyType == typeof(Vector2))
                    {
                        sProp = new SerializableComponentProperty();
                        sProp.propertyName  = pinfo.Name;
                        sProp.propertyValue = new SerializableVector2((Vector2)pinfo.GetValue(component, null)).GetString();
                        sProp.propertyType  = 5;
                        sComponent.properties.Add(sProp);
                    }
                    else if (pinfo.PropertyType == typeof(GameObject) && pinfo.GetValue(component, null) != null)
                    {
                        SerializableGameObjectReference sGObjectReference = new SerializableGameObjectReference()
                        {
                            gameObjectReferenceName = ((GameObject)pinfo.GetValue(component, null)).name
                        };
                        gameObjectsSerializableReferences.Add(sGObjectReference);
                        referencedGameObjects.Add((GameObject)pinfo.GetValue(component, null));

                        sProp = new SerializableComponentProperty();
                        sProp.propertyName = pinfo.Name;
                        //sProp.propertyValue
                        sProp.propertyType = 6;
                        sComponent.properties.Add(sProp);
                        objectReferenceProperties.Add(sProp);
                    }
                    else if ((pinfo.PropertyType == typeof(Component) || pinfo.PropertyType.IsSubclassOf(typeof(Component))) &&
                             pinfo.GetValue(component, null) != null)
                    {
                        SerializableComponentReference sComponentReference = new SerializableComponentReference()
                        {
                            componentReferenceName = ((Component)pinfo.GetValue(component, null)).GetType().Name
                        };
                        componentsSerializableReferences.Add(sComponentReference);
                        referencedComponents.Add((Component)pinfo.GetValue(component, null));

                        sProp = new SerializableComponentProperty();
                        sProp.propertyName = pinfo.Name;
                        //sProp.propertyValue
                        sProp.propertyType = 7;
                        sComponent.properties.Add(sProp);
                        componentReferenceProperties.Add(sProp);
                    }
                }
                catch {}
            }
        }

        FieldInfo[] finfos = type.GetFields(flags);
        foreach (var finfo in finfos)
        {
            if (finfo.FieldType == typeof(string) ||
                finfo.FieldType == typeof(int) ||
                finfo.FieldType == typeof(float) ||
                finfo.FieldType == typeof(bool))
            {
                sProp = new SerializableComponentProperty();
                sProp.propertyName = finfo.Name;
                if (finfo.FieldType == typeof(string) && finfo.GetValue(component) == null)
                {
                    sProp.propertyValue = "";
                }
                else
                {
                    sProp.propertyValue = finfo.GetValue(component).ToString();
                }

                if (finfo.FieldType == typeof(string))
                {
                    sProp.propertyType = 0;
                }
                else if (finfo.FieldType == typeof(int))
                {
                    sProp.propertyType = 1;
                }
                else if (finfo.FieldType == typeof(float))
                {
                    sProp.propertyType = 2;
                }
                else if (finfo.FieldType == typeof(bool))
                {
                    sProp.propertyType = 3;
                }
                sComponent.properties.Add(sProp);
            }
            else if (finfo.FieldType == typeof(Vector3))
            {
                sProp = new SerializableComponentProperty();
                sProp.propertyName  = finfo.Name;
                sProp.propertyValue = new SerializableVector3((Vector3)finfo.GetValue(component)).GetString();
                sProp.propertyType  = 4;
                sComponent.properties.Add(sProp);
            }
            else if (finfo.FieldType == typeof(Vector2))
            {
                sProp = new SerializableComponentProperty();
                sProp.propertyName  = finfo.Name;
                sProp.propertyValue = new SerializableVector2((Vector2)finfo.GetValue(component)).GetString();
                sProp.propertyType  = 5;
                sComponent.properties.Add(sProp);
            }
            else if (finfo.FieldType == typeof(GameObject) && ((GameObject)finfo.GetValue(component)) != null)
            {
                SerializableGameObjectReference sGObjectReference = new SerializableGameObjectReference()
                {
                    gameObjectReferenceName = ((GameObject)finfo.GetValue(component)).name
                };
                gameObjectsSerializableReferences.Add(sGObjectReference);
                referencedGameObjects.Add((GameObject)finfo.GetValue(component));

                sProp = new SerializableComponentProperty();
                sProp.propertyName = finfo.Name;
                //sProp.propertyValue
                sProp.propertyType = 6;
                sComponent.properties.Add(sProp);
                objectReferenceProperties.Add(sProp);
            }
            else if ((finfo.FieldType == typeof(Component) || finfo.FieldType.IsSubclassOf(typeof(Component))) &&
                     finfo.GetValue(component) != null)
            {
                SerializableComponentReference sComponentReference = new SerializableComponentReference()
                {
                    componentReferenceName = ((Component)finfo.GetValue(component)).GetType().Name
                };
                componentsSerializableReferences.Add(sComponentReference);
                referencedComponents.Add((Component)finfo.GetValue(component));

                sProp = new SerializableComponentProperty();
                sProp.propertyName = finfo.Name;
                //sProp.propertyValue
                sProp.propertyType = 7;
                sComponent.properties.Add(sProp);
                componentReferenceProperties.Add(sProp);
            }
        }

        return(sComponent);
    }
示例#14
0
    Serializable Serialize(GameObject sObject)
    {
        Serializable output = new Serializable();
        CustomScript cs     = sObject.GetComponent <CustomScript>();

        for (int j = 0; j < cs.componentList.Length; j++)
        {
            /*Adds the Transform object for serialization*/
            if (cs.componentList[j].GetType().Name.Contains("Transform"))
            {
                Debug.Log("Added Transform");
                SerializableTransform sTransform = new SerializableTransform();
                sTransform.name     = "Transform";
                sTransform.position = cs.gameObject.transform.position;
                sTransform.rotation = cs.gameObject.transform.eulerAngles;
                sTransform.scale    = cs.gameObject.transform.localScale;
                output.components.Add(sTransform);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Renderable"))
            {
                SerializableMesh sRenderable = new SerializableMesh();
                sRenderable.name = "Renderable";
                Renderable r = cs.gameObject.GetComponent <Renderable>();
                if (sRenderable != null)
                {
                    sRenderable.mesh      = r.data.mesh;
                    sRenderable.material  = r.data.material;
                    sRenderable.albedo    = r.data.albedo;
                    sRenderable.metal     = r.data.metal;
                    sRenderable.roughness = r.data.roughness;
                    sRenderable.normal    = r.data.normal;
                    sRenderable.height    = r.data.height;
                    sRenderable.ao        = r.data.ao;
                    sRenderable.emissive  = r.data.emissive;
                }
                output.components.Add(sRenderable);
            }
            else if (cs.componentList[j].GetType().Name.Contains("MeshFilter"))                /*Adds the MeshFilter object for serialization*/
            {
                Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update");
                //Debug.Log("Added MeshFilter");
                //SerializableMesh sMesh = new SerializableMesh();
                //sMesh.name = "MeshFilter";
                //MeshFilter mf = cs.gameObject.GetComponent<MeshFilter>();
                //MeshRenderer mr = cs.gameObject.GetComponent < MeshRenderer>();
                //sMesh.mesh = mf.sharedMesh.name;
                //sMesh.material = mr.sharedMaterial.name;
                //sMesh.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;
                //output.components.Add(sMesh);
            }
            else if (cs.componentList[j].GetType().Name.Contains("MeshRenderer"))                /*Adds the MeshRenderer object for serialization*/
            {
                Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update");
                //    Debug.Log("Added MeshRenderer");
                //    SerializableMeshRenderer sMeshRenderer = new SerializableMeshRenderer();
                //    sMeshRenderer.name = "MeshRenderer";
                //    MeshRenderer mr = cs.gameObject.GetComponent<MeshRenderer>();
                //    sMeshRenderer.material = mr.sharedMaterial.name;
                //    sMeshRenderer.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;

                //    output.components.Add(sMeshRenderer);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Rigidbody"))                /*Adds the Rigidbody object for serialization */
            {
                Debug.Log("Added Rigidbody");
                SerializableRigidbody sRigidbody = new SerializableRigidbody();
                sRigidbody.name = "Rigidbody";
                Rigidbody rb = cs.gameObject.GetComponent <Rigidbody>();
                sRigidbody.mass        = rb.mass;
                sRigidbody.drag        = rb.drag;
                sRigidbody.angularDrag = rb.angularDrag;
                sRigidbody.useGravity  = rb.useGravity;
                sRigidbody.isKinematic = rb.isKinematic;
                sRigidbody.freezeXPos  = rb.constraints == RigidbodyConstraints.FreezePositionX;
                sRigidbody.freezeYPos  = rb.constraints == RigidbodyConstraints.FreezePositionY;
                sRigidbody.freezeZPos  = rb.constraints == RigidbodyConstraints.FreezePositionZ;
                sRigidbody.freezeXRot  = rb.constraints == RigidbodyConstraints.FreezeRotationX;
                sRigidbody.freezeYRot  = rb.constraints == RigidbodyConstraints.FreezeRotationY;
                sRigidbody.freezeZRot  = rb.constraints == RigidbodyConstraints.FreezeRotationZ;

                output.components.Add(sRigidbody);
            }
            else if (cs.componentList[j].GetType().Name.Contains("Collider"))                /*Adds the Collider object for serialization*/
            {
                Debug.Log("Added Collider");

                if (cs.gameObject.GetComponent <BoxCollider>())
                {
                    SerializableBoxCollider sBCollider = new SerializableBoxCollider();
                    sBCollider.name = "BoxCollider";
                    BoxCollider bc = cs.gameObject.GetComponent <BoxCollider>();
                    sBCollider.isTrigger = bc.isTrigger;
                    sBCollider.center    = bc.center;
                    sBCollider.size      = bc.size;
                    output.components.Add(sBCollider);
                }
                else if (cs.gameObject.GetComponent <SphereCollider>())
                {
                    SerializableSphereCollider sSCollider = new SerializableSphereCollider();
                    sSCollider.name = "SphereCollider";
                    SphereCollider sc = cs.gameObject.GetComponent <SphereCollider>();
                    sSCollider.isTrigger = sc.isTrigger;
                    sSCollider.center    = sc.center;
                    sSCollider.radius    = sc.radius;
                    output.components.Add(sSCollider);
                }
            }
            else
            {
                SerializableComponent Script = new SerializableComponent();
                string fName = cs.componentList[j].GetType().ToString();
                if (cs.componentList[j].GetType().ToString().Contains("UnityEngine."))
                {
                    Debug.Log(fName.Length);
                    Script.name = fName.Substring(12);
                }
                else
                {
                    Script.name = fName;
                }
                output.components.Add(Script);
            }
        }
        return(output);
    }