コード例 #1
0
    /*
     * Saves an Object
     * 'i' is the number of the object we are saving.
     */
    private void SaveObject(GameObject obj, int i, string file)
    {
        // Let's get the UniqueID object, as we'll need this.
        UniqueID uID = obj.GetComponent <UniqueID>();


        //Note that we're appending the 'i' to the end of the path so that
        //we know which object each piece of data belongs to.
        ES2.Save(uID.id, file + "?tag=uniqueID" + i);
        ES2.Save(uID.prefabName, file + "?tag=prefabName" + i);

        // You could add many more components here, inlcuding custom components.
        // For simplicity, we're only going to save the Transform component.
        Transform t = obj.GetComponent <Transform>();

        if (t != null)
        {
            ES2.Save(t, file + "?tag=transform" + i);
            // We'll also save the UniqueID of the parent object here, or -1
            // string if it doesn't have a parent.
            UniqueID parentuID = UniqueID.FindUniqueID(t.parent);
            if (parentuID == null)
            {
                ES2.Save(-1, file + "?tag=parentID" + i);
            }
            else
            {
                ES2.Save(parentuID.id, file + "?tag=parentID" + i);
            }
        }
    }