Пример #1
0
        public ProjectAsyncOperation <AssetItem[]> CreatePrefab(ProjectItem dropTarget, ExposeToEditor dragObject, bool?includeDependencies, Action <AssetItem[]> done)
        {
            SelectionGizmoModel gizmo = dragObject.GetComponentInChildren <SelectionGizmoModel>();

            if (gizmo != null)
            {
                gizmo.transform.SetParent(null);
                gizmo.gameObject.SetActive(false);
            }

            Action <AssetItem[]> callback = assetItems =>
            {
                if (gizmo != null)
                {
                    gizmo.transform.SetParent(dragObject.transform);
                    gizmo.gameObject.SetActive(true);
                }

                if (done != null)
                {
                    done(assetItems);
                }
            };

            ProjectAsyncOperation <AssetItem[]> ao = new ProjectAsyncOperation <AssetItem[]>();

            if (!includeDependencies.HasValue)
            {
                m_wm.Confirmation(
                    m_localization.GetString("ID_RTEditor_CreatePrefab", "Create Prefab"),
                    m_localization.GetString("ID_RTEditor_IncludeDependencies", "Include dependencies?"),
                    (sender, args) =>
                {
                    CreatePrefabWithDependencies(dropTarget, dragObject, result => OnCreatePrefabWithDepenenciesCompleted(result, ao, callback));
                },
                    (sender, args) =>
                {
                    CreatePrefabWithoutDependencies(dropTarget, dragObject, result => OnCreatePrefabWithDepenenciesCompleted(result, ao, callback));
                },
                    m_localization.GetString("ID_RTEditor_Yes", "Yes"),
                    m_localization.GetString("ID_RTEditor_No", "No"));
            }
            else
            {
                if (includeDependencies.Value)
                {
                    CreatePrefabWithDependencies(dropTarget, dragObject, result => OnCreatePrefabWithDepenenciesCompleted(result, ao, callback));
                }
                else
                {
                    CreatePrefabWithoutDependencies(dropTarget, dragObject, result => OnCreatePrefabWithDepenenciesCompleted(result, ao, callback));
                }
            }

            return(ao);
        }