public void UpdateAssetAtIndex(ActorableSearchResult newResult, int index) { assetToolbarAssets[index] = newResult; toolbarItems[index].SetTexture(newResult.thumbnail); EmptyAssetToolbarRenderable(index); assetSearch.RequestRenderable(assetToolbarAssets[index].renderableReference, renderableObj => SetAssetToolbarRenderable(renderableObj, newResult, index)); }
IEnumerator LoadThumbnail(ImageResult imageResult, OnActorableSearchResult resultCallback) { if (imageResult.thumbnailUrl.IsNullOrEmpty()) { yield break; } WWW temp = new WWW(imageResult.thumbnailUrl); yield return(temp); if (temp == null || !temp.error.IsNullOrEmpty()) { yield break; } ActorableSearchResult _newresult = new ActorableSearchResult(); _newresult.preferredRotation = Quaternion.identity; _newresult.preferredScaleFunction = (go) => new Vector3(1f, 1f, 1f); _newresult.renderableReference.assetType = AssetType.Image; _newresult.name = imageResult.name; _newresult.renderableReference.uri = new ImageVoosAsset(imageResult.url).GetUri(); _newresult.thumbnail = temp.texture; resultCallback(_newresult); }
public void TriggerActorSpawn( ActorableSearchResult result, Vector3 position, Quaternion rotation, Vector3 scale, System.Action <VoosActor> onActorCallback, bool isOffstage, Color tint, Vector3 renderableOffset, Quaternion renderableRotation) { // Do it locally with the full setup. SpawnActor spawnActor = GameObject.Instantiate(actorSpawner, Vector3.zero, Quaternion.identity).GetComponent <SpawnActor>(); spawnActor.onActorCreated = onActorCallback; spawnActor.isOffstage = isOffstage; spawnActor.SetTint(tint); spawnActor.Setup( result, position, rotation, scale, true, renderableOffset, renderableRotation); // Kick off RPC for others. photonView.RPC("TriggerActorSpawnEffectRPC", PhotonTargets.Others, (byte)result.renderableReference.assetType, result.renderableReference.uri, position + renderableOffset, renderableRotation * rotation, scale, tint); }
void PolyThumbnailCallback(PolyAsset asset, PolyStatus status, OnActorableSearchResult resultCallback) { if (!status.ok) { Debug.Log("There is a problem with poly stuff"); return; } ActorableSearchResult _newresult = new ActorableSearchResult(); _newresult.forceConcave = true; // Do this for Poly models, for now. _newresult.preferredRotation = Quaternion.identity; // Don't do any actor-level scaling for any of these hash tags if (asset.description.Contains(TerrainBlockHashtag) || asset.description.Contains(NoAutoFitHashtag)) { _newresult.preferredScaleFunction = _ => new Vector3(1f, 1f, 1f); } else { // Do some custom tuned actor scale. _newresult.preferredScaleFunction = CalculatePreferredScale; } _newresult.renderableReference.assetType = AssetType.Poly; _newresult.name = asset.displayName; _newresult.renderableReference.uri = new PolyVoosAsset(asset.name).GetUri(); _newresult.thumbnail = asset.thumbnailTexture; resultCallback(_newresult); }
private void OnPickedFromCreationLibrary(ActorableSearchResult searchResult) { VoosActor actor = assetSearch.RequestActor(searchResult, Vector3.zero, Quaternion.identity, Vector3.one); actor.SetPreferOffstage(true); CloseAndReturn(true, actor.GetName()); }
IEnumerator TestRenderableRoutine(ActorableSearchResult _requestedResult, RenderableRequestEventHandler requestCallback, int index) { // yield return new WaitForSeconds(Random.Range(.2f, .5f)); yield return(null); requestCallback(Instantiate(testRenderable)); }
public void RequestRenderable(ActorableSearchResult _requestedResult, RenderableRequestEventHandler requestCallback, int index) { if (testRenderableRoutine != null) { StopCoroutine(testRenderableRoutine); } testRenderableRoutine = StartCoroutine(TestRenderableRoutine(_requestedResult, requestCallback, index)); }
void LoadDefaultAssets() { for (int i = 0; i < 4; i++) { ActorableSearchResult newResult = assetSearch.GetBuiltInSearchResult(defaultAssets[i]); UpdateAssetAtIndex(newResult, i); } }
public VoosActor RequestActor(ActorableSearchResult _requestedResult, Vector3 rootSpawnPosition, Quaternion additionalRotation, Vector3 spawnScale) { Quaternion spawnRotation = additionalRotation * _requestedResult.preferredRotation; // NOTE: We could also have additionalScale here, in which case we'd want to multiply it with preferredLocalScale and apply it. // If, for example, the new tool gave you the ability to scale (like it lets you rotate now). if (_requestedResult.renderableReference.assetType == AssetType.Actor || _requestedResult.renderableReference.assetType == AssetType.AssetPack) { return(_requestedResult.actorPrefab.Instantiate(voosEngine, behaviorSystem, rootSpawnPosition, spawnRotation, setupActor => { // IMPORTANT! The setupActor could be a child of the hierarchy! So the // position is not necessarily rootSpawnPosition. setupActor.SetSpawnPosition(setupActor.transform.position); setupActor.SetSpawnRotation(setupActor.transform.rotation); // Post-setup for effect results string pfxId = _requestedResult.pfxId; if (pfxId != null) { setupActor.SetPfxId(pfxId); ParticleEffect pfx = particleEffectSystem.GetParticleEffect(pfxId); if (pfx != null) { setupActor.SetDisplayName(pfx.name); } } string sfxId = _requestedResult.sfxId; if (sfxId != null) { setupActor.SetSfxId(sfxId); SoundEffect sfx = soundEffectSystem.GetSoundEffect(sfxId); if (sfx != null) { setupActor.SetDisplayName(sfx.name); } } })); } else { return(voosEngine.CreateActor(rootSpawnPosition, spawnRotation, actor => { if (_requestedResult.forceConcave) { actor.SetUseConcaveCollider(true); } actor.SetLocalScale(spawnScale); actor.SetDisplayName(_requestedResult.name); actor.SetRenderableUri(_requestedResult.renderableReference.uri); })); } }
void OnResult(ActorableSearchResult incomingResult, bool isInternal) { // Ignore pfx/sfx results, they are loaded already if (incomingResult.name == "Empty" && incomingResult.name == "Sound") { return; } SquareImageButtonUI newResult = Instantiate(creationLibraryUI.resultsPrefab, creationLibraryUI.resultsRect); newResult.SetImage(incomingResult.thumbnail); newResult.onPointerDown = () => ResultClicked(newResult); newResult.SetSearchResult(incomingResult); ItemWithTooltipWithEventSystem tooltip = newResult.gameObject.AddComponent <ItemWithTooltipWithEventSystem>(); tooltip.SetupWithUserMain(userMain); tooltip.SetDescription(incomingResult.name); // int categoryValue = creationLibraryUI.categoryDropdown.value; if (isInternal) { internalResults.Add(newResult); // if (incomingResult.actorPrefab != null && !sceneActorLibrary.Exists(incomingResult.actorPrefab.GetId())) // { // DropdownCategoryPut(incomingResult.actorPrefab.GetAssetPackName()); // } if (sceneActorLibrary.Exists(incomingResult.actorPrefab.GetId())) { SetResultShowing(newResult, selectedCategory == CATEGORY_CUSTOM || selectedCategory == null || selectedCategory == CATEGORY_ALL); } else { UpdateInternalResultShowing(newResult); } } else { webResults.Add(newResult); if (incomingResult.renderableReference.assetType == AssetType.Poly) { SetResultShowing(newResult, selectedCategory == CATEGORY_POLY); } else if (incomingResult.renderableReference.assetType == AssetType.Image) { SetResultShowing(newResult, selectedCategory == CATEGORY_GIS); } } }
void UpdateAsset(ActorableSearchResult result) { this.result = result; ActorableSearchResult tempResult = result; createToolPreview.SetRenderableByReference( result.renderableReference, GetAdditionalRotation(), result.GetRenderableOffset(), result.preferredRotation, result.preferredScaleFunction, () => { return(tempResult.renderableReference.uri == this.result.renderableReference.uri); }); }
ActorableSearchResult CreateTestResult() { ActorableSearchResult testresult = new ActorableSearchResult(); testresult.preferredRotation = Quaternion.identity; testresult.renderableReference.assetType = AssetType.Poly; testresult.name = "test name"; testresult.renderableReference.uri = "test uri"; // TODO testresult.thumbnail = testThumbnail.texture; return(testresult); }
void SetAssetToolbarRenderable(GameObject _gameobject, ActorableSearchResult _requestedResult, int index) { if (_requestedResult.renderableReference.uri == assetToolbarAssets[index].renderableReference.uri) { _gameobject.transform.rotation = _requestedResult.preferredRotation; _gameobject.transform.localScale = _requestedResult.preferredScaleFunction(_gameobject); SetAssetToolbarObject(index, _gameobject); } else { Destroy(_gameobject); Debug.Log("renderable callback out of date"); } }
void TriggerActorSpawnEffectRPC(byte assetType, string uri, Vector3 position, Quaternion rotation, Vector3 scale, Color tint) { SpawnActor spawnActor = GameObject.Instantiate(actorSpawner, position, rotation).GetComponent <SpawnActor>(); ActorableSearchResult dummyResult = new ActorableSearchResult { renderableReference = new RenderableReference { assetType = (AssetType)assetType, uri = uri } }; spawnActor.SetTint(tint); spawnActor.Setup( dummyResult, position, rotation, scale, false, // This is just the preview, assume these offset are baked in. To save banwidth Vector3.zero, Quaternion.identity ); }
void OnCreationLibraryResult(ActorableSearchResult _result) { string prevRenderableUri = actor.GetRenderableUri(); string newRenderableUri = _result.renderableReference.uri; undoStack.PushUndoForActor( actor, $"Set asset for {actor.GetDisplayName()}", actor => { actor.SetRenderableUri(newRenderableUri); actor.ApplyPropertiesToClones(); }, actor => { actor.SetRenderableUri(prevRenderableUri); actor.ApplyPropertiesToClones(); }); creationLibrary.gameObject.SetActive(false); }
void OnResult(ActorableSearchResult incomingResult, bool isInternal) { // hacckk if (incomingResult.name == "Empty") { emptyActorTemplate = incomingResult; return; } SquareImageButtonUI newResult = Instantiate(renderableLibraryUI.resultsPrefab, renderableLibraryUI.resultsRect); newResult.SetImage(incomingResult.thumbnail); newResult.onPointerDown = () => ResultClicked(newResult); newResult.SetSearchResult(incomingResult); ItemWithTooltipWithEventSystem tooltip = newResult.gameObject.AddComponent <ItemWithTooltipWithEventSystem>(); tooltip.SetDescription(incomingResult.name); // int categoryValue = creationLibraryUI.categoryDropdown.value; if (isInternal) { internalResults.Add(newResult); } else { webResults.Add(newResult); if (incomingResult.renderableReference.assetType == AssetType.Poly) { SetResultShowing(newResult, selectedCategory == CATEGORY_POLY); } else if (incomingResult.renderableReference.assetType == AssetType.Image) { SetResultShowing(newResult, selectedCategory == CATEGORY_GIS); } } }
public void Setup( ActorableSearchResult result, Vector3 spawnPosition, Quaternion spawnRotation, Vector3 spawnScale, bool isLocal, Vector3 renderableOffset, Quaternion renderableRotation ) { // NOTE: Bit of a hack. When we're not local, 'result' only has the renderable reference set. None of the other data is relevant. this.result = result; this.spawnPosition = spawnPosition; this.spawnRotation = spawnRotation; this.spawnScale = spawnScale; this.isLocal = isLocal; this.renderableOffset = renderableOffset; this.renderableRotation = renderableRotation; assetSearch.RequestRenderable(result.renderableReference, OnRenderable); }
public ActorableSearchResult TurnPrefabIntoSearchResult(ActorPrefab prefab, AssetType assetType) { ActorableSearchResult _newresult = new ActorableSearchResult(); _newresult.preferredRotation = prefab.GetRenderableRotation(); _newresult.preferredScaleFunction = (go) => prefab.GetLocalScale(); _newresult.renderableReference.assetType = assetType; _newresult.name = prefab.GetLabel(); _newresult.renderableReference.uri = prefab.GetRenderableUri(); if (prefab.GetThumbnail() != null) { _newresult.thumbnail = prefab.GetThumbnail(); } else { // TODO just take a texture _newresult.thumbnail = defaultThumbnail.texture; } _newresult.actorPrefab = prefab; return(_newresult); }
public void ResetAsset() { ActorableSearchResult newResult = assetSearch.GetBuiltInSearchResult(defaultAssets[currentIndex]); UpdateAssetAtIndex(newResult, currentIndex); }
public override void Setup(SidebarManager _sidebarManager) { base.Setup(_sidebarManager); Util.FindIfNotSet(this, ref editMain); Util.FindIfNotSet(this, ref userMain); Util.FindIfNotSet(this, ref assetSearch); Util.FindIfNotSet(this, ref sceneActorLibrary); Util.FindIfNotSet(this, ref popups); ShouldShowInternalResult = (result) => { return(false); }; lastResult = assetSearch.GetBuiltInSearchResult("Forest/Slime"); creationLibraryUI.searchInput.onEndEdit.AddListener(OnInputFieldEnd); creationLibraryUI.clearSearchButton.onClick.AddListener(ClearSearch); sceneActorLibrary.onActorPut += OnActorPut; sceneActorLibrary.onActorDelete += OnActorDelete; assetSearch.AddPrefabsProcessor((searchResult) => OnResult(searchResult, true)); List <Util.Tuple <string, Texture2D> > allCategories = new List <Util.Tuple <string, Texture2D> >(); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_ALL, allCategoryIcon)); foreach (CategoryButton category in dynamicCategories) { allCategories.Add(new Util.Tuple <string, Texture2D>(category.displayName, category.icon)); } allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_DECORATIONS, decorationCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_CUSTOM, savedCategoryIcon)); //NO_POLY_TOOLKIT_INTERNAL_CHECK if (!PolyToolkitInternal.PtSettings.Instance.authConfig.apiKey.Contains("INSERT YOUR")) { allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_POLY, polyCategoryIcon)); } if (GisSearchManager.APIkey != "PUT YOUR KEY HERE") { allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_GIS, gisCategoryIcon)); } allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_PARTICLES, particlesCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_SOUNDS, soundsCategoryIcon)); foreach (Util.Tuple <string, Texture2D> categoryTuple in allCategories) { string category = categoryTuple.first; Texture2D texture = categoryTuple.second; TextIconButtonUI categoryButton = Instantiate( creationLibraryUI.categoryButtonPrefab, creationLibraryUI.categoriesList.transform); categoryButton.text.text = category; categoryButton.icon.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0)); categoryButton.button.onClick.AddListener(() => { selectedCategory = category; UpdateAll(); }); if (category == CATEGORY_CHALLENGE) { categoryButton.medallion.gameObject.SetActive(true); } categoryButton.gameObject.SetActive(true); } creationLibraryUI.inCategoryBackButton.onClick.AddListener(() => { selectedCategory = null; ClearSearch(); //includes update all // UpdateAll(); }); particleLibrary.Setup(); particleLibrary.onParticleEffectSelected += OnParticleEffectSelected; soundLibrary.onSoundSelected += OnSoundEffectSelected; soundLibrary.Setup(); creationLibraryUI.inCategoryLink.onClick.AddListener(() => { Application.OpenURL(challengeCategoryUrl); }); #if USE_STEAMWORKS actorPrefabUploadDialog = Instantiate(actorPrefabUploadDialogPrefab); actorPrefabUploadDialog.Setup(); actorPrefabWorkshopMenu = Instantiate(actorPrefabWorkshopMenuPrefab); actorPrefabWorkshopMenu.Setup(); #endif creationLibraryUI.exportDropdownMenu.onOptionClicked += (value) => { SquareImageButtonUI exportResult = selectedResult; Debug.Assert(selectedResult != null); ActorPrefab prefab = exportResult.GetSearchResult().actorPrefab; Debug.Assert(sceneActorLibrary.Exists(prefab?.GetId())); if (value == EXPORT_TO_DISK) { ExportToDisk(prefab); } #if USE_STEAMWORKS else if (value == UPDATE_WORKSHOP_PREFAB) { ulong?id = GetWorkshopIdForActor(prefab); actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateWith(id.Value)); } else { actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateEmpty()); } #endif }; #if USE_STEAMWORKS creationLibraryUI.importDropdownMenu.SetOptions(new List <string>() { IMPORT_FROM_DISK, IMPORT_FROM_WORKSHOP }); #else creationLibraryUI.importCustomButton.onClick.AddListener(ImportFromDisk); #endif creationLibraryUI.importDropdownMenu.onOptionClicked += (value) => { if (value == IMPORT_FROM_DISK) { ImportFromDisk(); } else { actorPrefabWorkshopMenu.Open(); } }; pfxActorTemplate = assetSearch.GetBuiltInSearchResult("Empty"); sfxActorTemplate = assetSearch.GetBuiltInSearchResult("Sound"); }
void UpdateResult(ActorableSearchResult newResult) { lastResult = newResult; updateAsset?.Invoke(newResult); }
public void UpdateAsset(ActorableSearchResult newResult) { UpdateAssetAtIndex(newResult, currentIndex); }
public void SetSearchResult(ActorableSearchResult searchResult) { this.searchResult = searchResult; workshopMarker.SetActive( searchResult.actorPrefab != null && !searchResult.actorPrefab.GetWorkshopId().IsNullOrEmpty()); }