コード例 #1
0
    static internal void ExportB()
    {
        if (IsSelectingSingleGameObject())
        {
            var go   = Selection.activeGameObject;
            var path = UnityEditorExtensions.ShowExportDialog("Export to DataNode", go.name);

            if (!string.IsNullOrEmpty(path))
            {
                EditorUtility.DisplayCancelableProgressBar("Working", "Creating a DataNode...", 0f);
                ComponentSerialization.ClearReferences();
                var data = go.Serialize(true, true, true);
                if (data != null)
                {
                    Save(data, path, DataNode.SaveType.Binary);
                }
                ComponentSerialization.ClearReferences();
                EditorUtility.ClearProgressBar();
            }
        }
        else
        {
            ExportAssets(DataNode.SaveType.Binary);
        }
    }
コード例 #2
0
    /// <summary>
    /// Asset Bundle-like export, except using DataNode's deep serialization.
    /// </summary>

    static internal void ExportAssets(DataNode.SaveType type)
    {
        var path = UnityEditorExtensions.ShowExportDialog("Export to DataNode", "Assets");

        if (!string.IsNullOrEmpty(path))
        {
            ExportAssets(type, path);
        }
    }
コード例 #3
0
    static internal void ExportD()
    {
        var go   = Selection.activeGameObject;
        var path = UnityEditorExtensions.ShowExportDialog("Export AssetBundle", go.name);

        if (!string.IsNullOrEmpty(path))
        {
            var node      = new DataNode(go.name, go.GetInstanceID());
            var selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

            if (BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
                                               BuildAssetBundleOptions.CollectDependencies |
                                               BuildAssetBundleOptions.CompleteAssets,
                                               BuildTarget.StandaloneWindows))
            {
                node.AddChild("assetBundle", System.IO.File.ReadAllBytes(path));
                Save(node, path, DataNode.SaveType.Binary);
            }
        }
    }