Example #1
0
        public static async Task LoadPrefab(int uid)
        {
            if (loadingAsset)
            {
                return;
            }
            if (uid == -1)
            {
                return;
            }
            if (!items.TryGetValue(uid, out AssetBankItemData data))
            {
                return;
            }

            if (null == data.prefab)
            {
                loadingAsset = true;
                GlobalState.Instance.messageBox.ShowMessage("Loading asset, please wait...");
                Selection.ClearSelection();
                data.prefab = await data.importFunction(data);

                Utils.NameObjectMeshes(data.prefab);
                data.imported = true;
                GlobalState.Instance.messageBox.SetVisible(false);
                loadingAsset = false;
            }
        }
Example #2
0
 public static void Clear()
 {
     undoStack.Clear();
     redoStack.Clear();
     groupStack.Clear();
     Selection.ClearSelection();
     currentGroup = null;
 }
Example #3
0
        public async Task OnInstantiateUIObject()
        {
            if (loadingAsset)
            {
                return;
            }
            if (selectedItem == -1)
            {
                return;
            }
            if (!items.TryGetValue(selectedItem, out AssetBankItem item))
            {
                return;
            }
            if (!item.thumbnail.GetComponent <UIGrabber>().isValid)
            {
                return;
            }

            // If the original doesn't exist, load it
            if (null == item.prefab)
            {
                loadingAsset = true;
                GlobalState.Instance.messageBox.ShowMessage("Loading asset, please wait...");
                Selection.ClearSelection();
                item.prefab = await item.importFunction(item);

                NameObjectMeshes(item.prefab);
                item.imported = true;

                // For blender assets, we don't want to instantiate objects, we will receive them
                if (!item.skipInstantiation)
                {
                    AddObject(item.prefab);
                }
                else
                {
                    item.prefab = null;
                }
                GlobalState.Instance.messageBox.SetVisible(false);
                loadingAsset = false;
            }
            else
            {
                if (!item.skipInstantiation)
                {
                    GameObject instance = SceneManager.InstantiateObject(item.prefab);
                    AddObject(instance);
                }
            }
            selectedItem = -1;
        }
Example #4
0
        public static void DeleteTransformChildren(Transform trans)
        {
            Debug.Log("Clear scene");
            Selection.ClearSelection();

            // sync reparent before async destroy
            GameObject tmp = new GameObject();

            for (int i = trans.childCount - 1; i >= 0; i--)
            {
                Transform child = trans.GetChild(i);
                if (child.name.StartsWith("__VRtist_"))
                {
                    continue;
                }

                child.parent = tmp.transform;
            }

            GameObject.Destroy(tmp);
        }