예제 #1
0
        public void RetryFromLastState()
        {
            if (BundleState == State.Error)
            {
                switch (LastState)
                {
                case State.Creating:
                    CreateAsset(AssetName);
                    break;

                case State.GettingUploadPath:
                    //GetUploadPath(currentAssetID);
                    currentAsset.AddData(this.PathToBundle);
                    break;

                case State.Uploading:
                    //GetUploadPath(currentAssetID);
                    currentAsset.AddData(this.PathToBundle);
                    break;

                default:
                    break;
                }
            }
        }
예제 #2
0
        //[MenuItem("Spaces/Create/(Re)Build Bundles")]
        //static void BuildAllAssetBundles(BuildTarget platform = BuildTarget.StandaloneWindows64)
        //{
        //    //Create the folder if it does not exist
        //    if (!System.IO.Directory.Exists(Spaces.Core.Constants.SPACES_BUNDLES))
        //        System.IO.Directory.CreateDirectory(Spaces.Core.Constants.SPACES_BUNDLES);

        //    //Create the bundles
        //    var manifest = BuildPipeline.BuildAssetBundles(Spaces.Core.Constants.SPACES_BUNDLES, BuildAssetBundleOptions.None, platform);
        //    Debug.Log("Bundle Count: " + manifest.GetAllAssetBundles().Length);
        //}

        //[MenuItem("Spaces/Create/Make Test Bundles")]
        //static void BuildAssetBundles()
        //{
        //    BuildTarget platform = BuildTarget.StandaloneWindows64;

        //    //Create the folder if it does not exist
        //    if (!System.IO.Directory.Exists("Bundles"))
        //        System.IO.Directory.CreateDirectory("Bundles");

        //    //Create the bundles
        //    var manifest = BuildPipeline.BuildAssetBundles("Bundles", BuildAssetBundleOptions.None, platform);
        //    Debug.Log("Bundle Count: " + manifest.GetAllAssetBundles().Length);
        //}

        //private void GetAvailableAssetBundles()
        //{
        //    if (bundles == null)
        //        bundles = new List<AvailableBundle>();
        //    else
        //        bundles.Clear();

        //    //Get all of the asset bundles in the asset bundle folder
        //    if (System.IO.Directory.Exists(Spaces.Core.Constants.SPACES_BUNDLES))
        //    {
        //        //Get all of the local asset bundles
        //        if (System.IO.File.Exists(Spaces.Core.Constants.SPACES_BUNDLES + "/AvailableBundles.json"))
        //        {
        //            try
        //            {
        //                var availableBundles = Spaces.Core.JSONTools.Load<List<AvailableBundle>>(Spaces.Core.Constants.SPACES_BUNDLES + "/AvailableBundles.json");

        //                foreach (var bundle in availableBundles)
        //                {
        //                    if (System.IO.File.Exists(bundle.PathToBundle))
        //                    {
        //                        bundle.onStateChanged += BundleUpdated;
        //                        bundles.Add(bundle);
        //                    }
        //                }
        //            }
        //            catch (System.Exception ex)
        //            {
        //                Debug.Log(ex);
        //            }
        //        }

        //        //Get all of the local asset bundles
        //        foreach (string file in
        //            System.IO.Directory.GetFiles(Spaces.Core.Constants.SPACES_BUNDLES)
        //            .Where(file => string.IsNullOrEmpty(System.IO.Path.GetExtension(file)) && System.IO.File.Exists(file + ".manifest")))
        //        {
        //            if (!bundles.Any(b => b.PathToBundle == file.Replace("\\", "/")))
        //            {
        //                var bundle = new AvailableBundle(file.Replace("\\", "/"));
        //                bundle.onStateChanged += BundleUpdated;
        //                bundles.Add(bundle);
        //            }
        //        }

        //        bundles.Sort((b1, b2) => b1.BundleName.CompareTo(b2.BundleName));

        //        bundlesUpdated = true;
        //    }
        //}


        private void AssetUpdated(Core.Asset sender, Core.Asset.Process[] currentState, Core.Asset.Process endingState)
        {
            if (endingState == Core.Asset.Process.Deleting)
            {
                sender.onProcessEnd -= AssetUpdated;
            }

            // Asset creation steps
            if (endingState == Core.Asset.Process.Creating)
            {
                if (assetData.ContainsKey(sender) && !string.IsNullOrEmpty(assetData[sender].updatedResourcePath))
                {
                    sender.AddData(assetData[sender].updatedResourcePath);
                }
            }
            else if (endingState == Core.Asset.Process.Fetching && !string.IsNullOrEmpty(sender.assetType))
            {
                if (!assetTypeList.Contains(sender.assetType.ToLower()))
                {
                    assetTypeList.Add(sender.assetType.ToLower());
                }

                if (sender.assetType == Core.Constants.AssetType.image.ToString() && sender.previewUrl == "NONE")
                {
                    if (thumbs == null)
                    {
                        thumbs = new List <ThumbFetch>();
                    }

                    sender.previewUrl = sender.pathToData;
                    thumbs.Add(new ThumbFetch(sender));
                }
            }
            else if (endingState == Core.Asset.Process.FetchingPreviewPath)
            {
                if (thumbs == null)
                {
                    thumbs = new List <ThumbFetch>();
                }

                if (sender.previewUrl != "NONE")
                {
                    thumbs.Add(new ThumbFetch(sender));
                }
            }

            //if (state == State.FetchingAssets)
            //{
            //    if (assets.All(a => !a.InProcess(Core.Asset.Process.Fetching)))
            //    {
            //        UpdateState(State.Idle);
            //    }
            //}
            //else
            if (state == State.CreatingAsset)
            {
                if (assets.All(a => !a.InProcess(Core.Asset.Process.Creating)))
                {
                    UpdateState(State.Idle);
                }
            }
        }
예제 #3
0
        void DrawEditAssetPanel(Core.Asset asset)
        {
            Color bgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.green;//BG_COLOR_EVEN;

            using (var assetDetailPanel = new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MinHeight(ASSET_EDIT_PANEL_MIN_HEIGHT)))
            {
                using (var nameField = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Asset Name:", GUILayout.Width(160));
                    assetData[asset].updateAssetName = GUILayout.TextField(assetData[asset].updateAssetName);
                }

                using (var idField = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Asset ID:", GUILayout.Width(160));
                    EditorGUILayout.SelectableLabel(asset.id, GUILayout.Width(ASSET_ID_WIDTH), GUILayout.Height(EditorStyles.label.lineHeight + 1));
                }

                using (var typeField = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Asset Type:", GUILayout.Width(160));
                    assetData[asset].updateAssetTypeIndex = EditorGUILayout.Popup(assetData[asset].updateAssetTypeIndex, assetTypeList.ToArray(), GUILayout.Width(160));
                }

                using (var pathField = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Path to Data:", GUILayout.Width(160));
                    EditorGUILayout.SelectableLabel(asset.pathToData, GUILayout.ExpandWidth(true), GUILayout.Height(EditorStyles.label.lineHeight + 1));
                }

                EditorGUILayout.LabelField("");

                //if (assetData[asset].updateAssetTypeIndex > -1 && assetData[asset].updateAssetTypeIndex < assetTypeList.Count && asset.assetType.ToLower() == assetTypeList[assetData[asset].updateAssetTypeIndex] && !externalBundle)
                //{
                //    EditorGUILayout.BeginHorizontal();
                //    {
                //        EditorGUILayout.LabelField("Bundle:", GUILayout.Width(160));
                //        assetData[asset].updateBundleIndex = EditorGUILayout.Popup(assetData[asset].updateBundleIndex, bundles.Select(b => b.BundleName).ToArray(), GUILayout.Width(BUNDLE_NAME_WIDTH));

                //        bool wasEnabled = GUI.enabled;
                //        GUI.enabled = wasEnabled && (!asset.InProcess(Core.Asset.Process.Uploading) || !asset.InProcess(Core.Asset.Process.RequestingEndpoint));
                //        if (GUILayout.Button("Re-Upload", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                //        {
                //            asset.AddData(bundles[assetData[asset].updateBundleIndex].PathToBundle);
                //        }
                //        GUI.enabled = wasEnabled;

                //        if (assetData[asset].updateBundleIndex > -1 && assetData[asset].updateBundleIndex < bundles.Count)
                //            DrawStatus(bundles[assetData[asset].updateBundleIndex].GetStatusMessage());
                //    }
                //    EditorGUILayout.EndHorizontal();
                //}
                //else
                //{
                using (var filePathField = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Asset File Path:", GUILayout.Width(160));
                    assetData[asset].updatedResourcePath = EditorGUILayout.TextField(assetData[asset].updatedResourcePath);

                    bool wasEnabled = GUI.enabled;
                    GUI.enabled = wasEnabled && !asset.InProcess(Core.Asset.Process.Uploading);
                    if (GUILayout.Button("Re-Upload", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                    {
                        asset.AddData(assetData[asset].updatedResourcePath);
                    }
                    GUI.enabled = wasEnabled;
                }
                //}

                //if (asset.assetType == assetTypeList[assetData[asset].updateAssetTypeIndex])
                //    externalBundle = EditorGUILayout.Toggle("external bundle file", externalBundle, GUILayout.Width(160));

                EditorGUILayout.LabelField("", GUILayout.ExpandHeight(true));

                using (var graphButtonField = new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Open Graph", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                    {
                        Manager.SpaceGraphNodeViewer.OpenGraphViewer(asset);
                    }

                    if (GUILayout.Button("Reset to Default", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                    {
                        if (asset != null)
                        {
                            asset.ResetToDefault();
                        }
                    }

                    EditorGUILayout.LabelField("");
                    bool wasEnabled = GUI.enabled;
                    GUI.enabled = wasEnabled && assetData[asset].updateAssetName != asset.name;
                    if (GUILayout.Button("Update", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                    {
                        asset.Update(assetData[asset].updateAssetName, assetTypeList[assetData[asset].updateAssetTypeIndex], "", "");
                    }
                    GUI.enabled = wasEnabled;

                    if (GUILayout.Button("Cancel", GUILayout.Width(ASSET_WIDE_BUTTON_WIDTH)))
                    {
                        assetData.Remove(asset);
                        //externalBundle = false;
                    }
                }
            }
            GUI.backgroundColor = bgColor;
        }