private void UpdateScene(ISceneData sceneData) { var cardView = RemoveScene(sceneData, false); cardView.Setup(sceneData); AddScene(sceneData, cardView, false); }
private SceneCardView RemoveScene(ISceneData sceneData, bool notify) { bool wasDeployed = scenesRefreshHelper.WasDeployedScene(sceneData); var dictionary = wasDeployed ? scenesRefreshHelper.oldDeployedScenes : scenesRefreshHelper.oldProjectsScenes; if (dictionary.TryGetValue(sceneData.id, out SceneCardView sceneCardView)) { dictionary.Remove(sceneData.id); if (notify) { if (wasDeployed) { OnDeployedSceneRemoved?.Invoke(sceneCardView); } else { OnProjectSceneRemoved?.Invoke(sceneCardView); } } return(sceneCardView); } return(null); }
public virtual void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //Debug.Log("OnSceneLoaded: " + scene.name); //Debug.Log(scene.buildIndex); //Debug.Log(mode); SetupData(); if (NextSceneData == null) { Debug.LogWarning("No Next scene Data has Been Assigned"); if (nextSceneName != null) { NextSceneData = Resources.Load <ISceneData>("Alex/SceneData/SceneDataObjects/" + nextSceneName + "Data"); } } if (playerObjectToUse != null && playerObjectToUse.Length > 0) { PlayerStats players = FindObjectOfType <PlayerStats>(); for (int i = 0; i < players.GetPlayers().Count; i++) { //players.GetPlayerObjects()[i].SetActive(true); //players.GetPlayers()[i].GetObject().transform.DetachChildren(); GameObject obj = Instantiate(playerObjectToUse[i], players.GetPlayers()[i].GetObject().transform.position, players.GetPlayers()[i].GetObject().transform.rotation, players.GetPlayers()[i].GetObject().transform); obj.name = "Player_0" + i; // obj.GetComponent<MeshRenderer>().material.color = playerColors[i]; players.GetPlayers()[i].GetObject().transform.position = playerSpawnPoints[i]; players.GetPlayers()[i].GetObject().transform.LookAt(new Vector3(0, players.GetPlayers()[i].GetObject().transform.position.y, 0)); players.GetPlayers()[i].GetObject().AddComponent <PlayerScript>(); //Debug.Log(players.GetPlayers()[i].GetObject().transform.GetChild(0).gameObject.name); //Debug.Log(playerObjectToUse.name); } } }
public void Grabcommands() { while (true) { Debug.Log("waiting..."); Thread.Sleep(100); if (_commandRetriever.TryGrabCommand(out var commandName, out var commandValue)) { if (commandName.Equals(UnityEngineCommands.ReadTrialData)) { _dataRetriever.RetrieveData(commandValue, out _currentTrialMetaData); _currentUnijoySceneData = _sceneBuilder.Build(_currentTrialMetaData); NewSceneReceived.Invoke(this, _currentUnijoySceneData); } else if (commandName.Equals(UnityEngineCommands.VisualOperationCommand)) { if (commandValue.Equals(VisualOperationCommand.StartRender)) { StartRenderCommandReceived.Invoke(this, null); } else if (commandValue.Equals(VisualOperationCommand.CleanScreen)) { ClearRenderCommandReceied.Invoke(this, null); } } } } }
public ISceneData Build(IVisualTrialData trialData) { _sceneData = new UnijoySceneData() { ColorData = trialData.ColorData, X = trialData.X, Y = trialData.Y, Z = trialData.Z, RX = trialData.RX, RY = trialData.RY, RZ = trialData.RZ, ObjectType = trialData.ObjectType, //Source = trialData.Source, ObjectsVertices = new List <Vector3>(), Density = trialData.Density, Size = trialData.Size, Coherence = trialData.Coherence, StarFieldDimension = trialData.StarFieldDimension, ClipPlanes = trialData.ClipPlanes, ScreenDimension = trialData.ScreenDimension, EyeOffsets = trialData.EyeOffsets, HeadCenter = trialData.HeadCenter }; AddObjects(); return(_sceneData); }
private void CreateScene(ISceneData sceneData, bool shouldNotifyAdd) { var cardView = CreateCardView(); cardView.Setup(sceneData); AddScene(sceneData, cardView, shouldNotifyAdd); }
private void ChangeSceneDeployStatus(ISceneData sceneData, bool shouldNotifyAdd) { var cardView = RemoveScene(sceneData, true); cardView.Setup(sceneData); AddScene(sceneData, cardView, shouldNotifyAdd); }
void OnContextMenuOpen(ISceneData sceneData, ISceneCardView sceneCard) { contextMenu.transform.position = sceneCard.contextMenuButtonPosition; contextMenu.Show(sceneData.id, sceneData.isDeployed, sceneData.isOwner || sceneData.isOperator, sceneData.isContributor); sceneCoords = sceneData.coords; sceneSource = sceneData.source; }
public bool WasProjectScene(ISceneData sceneData) { if (isOldProjectScenesEmpty) { return(false); } return(oldProjectsScenes.ContainsKey(sceneData.id)); }
public bool WasDeployedScene(ISceneData sceneData) { if (isOldDeployedScenesEmpty) { return(false); } return(oldDeployedScenes.ContainsKey(sceneData.id)); }
public void Setup(ISceneData sceneData) { this.sceneData = sceneData; SetThumbnail(sceneData.thumbnailUrl); SetName(sceneData.name); SetCoords(sceneData.coords); SetSize(sceneData.size); SetDeployed(sceneData.isDeployed); SetUserRole(sceneData.isOwner, sceneData.isOperator, sceneData.isContributor); }
private IEnumerator SwapScenesCoroutine(ISceneData currentScene, ISceneData nextScene) { UnloadScene(currentScene); yield return(new WaitForSeconds(SceneTransitionController.ANIMATION_TIME)); SceneManager.UnloadSceneAsync(currentScene.SceneName); yield return(LoadSceneAndThen(nextScene.SceneName, LoadSceneMode.Additive, () => nextScene.OnLoad())); }
// called first // Assign Data and events void OnEnable() { if (myCurrentData == null) { myCurrentData = Resources.Load <ISceneData>("Alex/SceneData/SceneDataObjects/" + SceneManager.GetActiveScene().name + "Data"); myCurrentData.SetupData(); } SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.activeSceneChanged += ActiveSceneChanged; }
public void Update(ISceneData newSceneData) { Core.Logger.Debug($"Update called for {this.GetType().Name}"); var data = newSceneData as SceneData; if (data?.WorldDynamicId == AdvDia.CurrentWorldDynamicId) { LastUpdated = DateTime.UtcNow; OnUpdated(data); } }
public Dictionary <string, SceneCardView> GetOldDictionary(ISceneData sceneData) { if (WasDeployedScene(sceneData)) { return(oldDeployedScenes); } if (WasProjectScene(sceneData)) { return(oldProjectsScenes); } return(null); }
void SetProjectData(ISceneData sceneData) { viewReferences.titleLabel.text = sceneData.isDeployed ? SCENE_TITLE : PROJECT_TITLE; viewReferences.coordsContainer.SetActive(sceneData.isDeployed); viewReferences.sizeContainer.SetActive(!sceneData.isDeployed); viewReferences.entitiesCountContainer.SetActive(!sceneData.isDeployed); viewReferences.coordsText.text = $"{sceneData.coords.x},{sceneData.coords.y}"; viewReferences.sizeText.text = $"{sceneData.size.x},{sceneData.size.y}m"; viewReferences.entitiesCountText.text = sceneData.entitiesCount.ToString(); viewReferences.authorNameText.text = sceneData.authorName; viewReferences.adminsMenuToggle.gameObject.SetActive(sceneData.isDeployed); SetThumbnails(sceneData); }
public void Update(ISceneData newSceneData) { s_logger.Debug($"[{nameof(Update)}] called."); var data = newSceneData as SceneData; if (data?.WorldDynamicId != AdvDia.CurrentWorldDynamicId) { return; } LastUpdated = DateTime.UtcNow; OnUpdated(data); }
public void SetSceneData(ISceneData sceneData) { this.sceneData = sceneData; view.SetName(sceneData.name); view.SetDescription(sceneData.description); view.SetConfigurationActive(sceneData.isDeployed); view.SetPermissionsActive(sceneData.isDeployed); if (sceneData.isDeployed) { view.SetAllowMovePlayer(sceneData.requiredPermissions != null && sceneData.requiredPermissions.Contains(PERMISSION_MOVE_PLAYER)); view.SetAllowTriggerEmotes(sceneData.requiredPermissions != null && sceneData.requiredPermissions.Contains(PERMISSION_TRIGGER_EMOTES)); view.SetAllowVoiceChat(sceneData.allowVoiceChat); view.SetMatureContent(sceneData.isMatureContent); } }
private void AddScene(ISceneData sceneData, SceneCardView sceneCardView, bool notify) { var dictionary = sceneData.isDeployed ? deployedScenes : projectScenes; dictionary.Add(sceneData.id, sceneCardView); if (notify) { if (sceneData.isDeployed) { OnDeployedSceneAdded?.Invoke(sceneCardView); } else { OnProjectSceneAdded?.Invoke(sceneCardView); } } }
private void SetScene(ISceneData sceneData) { bool shouldNotifyAdd = (sceneData.isDeployed && !scenesRefreshHelper.isOldDeployedScenesEmpty) || (!sceneData.isDeployed && !scenesRefreshHelper.isOldProjectScenesEmpty); if (scenesRefreshHelper.IsSceneDeployStatusChanged(sceneData)) { ChangeSceneDeployStatus(sceneData, shouldNotifyAdd); } else if (scenesRefreshHelper.IsSceneUpdate(sceneData)) { UpdateScene(sceneData); } else { CreateScene(sceneData, shouldNotifyAdd); } }
void HandelNewData(object sender, ISceneData e) { try { Debug.Log("Start Handling new trial data"); for (int i = 0; i < e.Z.Count; i += 17) { _zTrajectory.Add(e.X[i]); } Debug.Log("Finish Handling new trial data"); _newData = true; } catch (Exception ex) { Debug.LogError($"Exception with {ex.ToString()}"); } }
void SetThumbnails(ISceneData sceneData) { if (string.IsNullOrEmpty(sceneData.authorThumbnail)) { viewReferences.avatarThumbnailContainer.SetActive(false); } else { if (promiseAvatarThumbnail != null) { AssetPromiseKeeper_Texture.i.Forget(promiseAvatarThumbnail); } promiseAvatarThumbnail = new AssetPromise_Texture(sceneData.authorThumbnail); promiseAvatarThumbnail.OnFailEvent += asset => viewReferences.avatarThumbnailContainer.SetActive(false); promiseAvatarThumbnail.OnSuccessEvent += asset => { viewReferences.avatarThumbnailContainer.SetActive(true); viewReferences.avatarImage.texture = asset.texture; }; AssetPromiseKeeper_Texture.i.Keep(promiseAvatarThumbnail); } if (string.IsNullOrEmpty(sceneData.thumbnailUrl)) { viewReferences.thumbnail.texture = defaultThumbnail; } else { if (promiseSceneThumbnail != null) { AssetPromiseKeeper_Texture.i.Forget(promiseSceneThumbnail); } promiseSceneThumbnail = new AssetPromise_Texture(sceneData.thumbnailUrl); promiseSceneThumbnail.OnFailEvent += asset => viewReferences.thumbnail.texture = defaultThumbnail; promiseSceneThumbnail.OnSuccessEvent += asset => { viewReferences.thumbnail.texture = asset.texture; }; AssetPromiseKeeper_Texture.i.Keep(promiseSceneThumbnail); } }
void HandelNewData(object sender, ISceneData e) { try { _vertices = e.ObjectsVertices.ToArray(); _vertexesIndexes = new int[_vertices.Length]; for (int i = 0; i < _vertexesIndexes.Length; i++) { _vertexesIndexes[i] = i; } Debug.Log("Handling new trial data"); _newData = true; } catch (Exception ex) { Debug.LogError($"Exception with {ex.ToString()}"); } }
void ISceneCardView.Setup(ISceneData sceneData) { this.sceneData = sceneData; string sceneThumbnailUrl = sceneData.thumbnailUrl; if (string.IsNullOrEmpty(sceneThumbnailUrl) && sceneData.parcels != null) { sceneThumbnailUrl = MapUtils.GetMarketPlaceThumbnailUrl(sceneData.parcels, THMBL_MARKETPLACE_WIDTH, THMBL_MARKETPLACE_HEIGHT, THMBL_MARKETPLACE_SIZEFACTOR); } ISceneCardView thisView = this; thisView.SetThumbnail(sceneThumbnailUrl); thisView.SetName(sceneData.name); thisView.SetCoords(sceneData.coords); thisView.SetSize(sceneData.size); thisView.SetDeployed(sceneData.isDeployed); thisView.SetUserRole(sceneData.isOwner, sceneData.isOperator, sceneData.isContributor); thisView.SetEditable(sceneData.isEditable); thisView.searchInfo.SetId(sceneData.id); }
// Makes sure a scene is fully loaded before searching for data to assign void ChangeScene(string nextSceneName) { //SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene()); //Debug.Log("Changing to new Scene"); Scene scene = SceneManager.GetSceneByName(myCurrentData.NextSceneName()); Debug.Log(myCurrentData.NextSceneName() + " : loading Data"); myCurrentData.levelCompleted.allowChange = 1; SceneManager.LoadScene(myCurrentData.NextSceneName()); myCurrentData = Resources.Load <ISceneData>("Alex/SceneData/SceneDataObjects/" + myCurrentData.NextSceneName() + "Data"); Debug.Log(myCurrentData.name + " Loaded"); myCurrentData.SetupData(); myNextSceneData = myCurrentData.NextSceneData; _changeScene = false; while (!scene.isLoaded) { return; } SceneManager.SetActiveScene(scene); }
private void UnloadScene(ISceneData currentScene) { sceneTransitionController.FadeToBlack(); currentScene.UnLoad(); }
public bool IsSceneDeployStatusChanged(ISceneData sceneData) { return((!sceneData.isDeployed && WasDeployedScene(sceneData)) || (sceneData.isDeployed && WasProjectScene(sceneData))); }
public void SwapScenes(ISceneData currentScene, ISceneData nextScene) { StartCoroutine(SwapScenesCoroutine(currentScene, nextScene)); }
private void OnSceneSettingsPressed(ISceneData sceneData) { OnRequestOpenUrl?.Invoke($"https://builder.decentraland.org/scenes/{sceneData.projectId}"); }
public virtual void SetNextScene(string sceneName) { nextSceneName = sceneName; NextSceneData = Resources.Load <ISceneData>("Alex/SceneData/SceneDataObjects/" + sceneName + "Data"); }