Exemplo n.º 1
0
        IEnumerator CreateAssetAtom(string uniqueAtomName, string pathToAsset, string prefabName, string nameOfGameObjectToFind, AtomCreatedEvent OnAtomCreated)
        {
            yield return(new WaitForSeconds(0.5f));

            Atom createdAtom = GetAtomById(uniqueAtomName);

            if (createdAtom == null)
            {
                SuperController.singleton.StartCoroutine(SuperController.singleton.AddAtomByType("CustomUnityAsset", uniqueAtomName, true));
                yield return(new WaitWhile(() => GetAtomById(uniqueAtomName) == null));

                createdAtom = GetAtomById(uniqueAtomName);
            }

            JSONStorable storable = createdAtom.GetStorableByID("asset");

            storable.SetUrlParamValue("assetUrl", pathToAsset);
            storable.SetStringChooserParamValue("assetName", prefabName);


            yield return(new WaitWhile(() => GameObject.Find(nameOfGameObjectToFind) == null));

            if (OnAtomCreated != null)
            {
                OnAtomCreated(createdAtom);
            }
        }