private void ApplyMusicEntry(MusicEntry music) { Assert.IsNotNull(music); audioSource.clip = AssetLoader.Load <AudioClip>(music.resourcePath); titleLabel.text = music.GetDisplayName(); progressBar.interactable = true; }
public virtual void SetImage(string imageName, bool fade = true) { this.RuntimeAssert(characterTextureMerger == null && textureChanger == null, "Do not use SetImage() when CharacterTextureMerger or OverlayTextureChanger exists."); if (imageName == currentImageName) { return; } Sprite sprite = AssetLoader.Load <Sprite>(System.IO.Path.Combine(imageFolder, imageName)); if (spriteChanger != null && spriteChanger.enabled && fade && !gameState.isMovingBack && dialogueBoxController.state != DialogueBoxState.Skip) { // If pose is not changing, do not hide body if (currentImageName != null && imageName[0] == currentImageName[0]) { spriteChanger.SetSprite(sprite, overlay: true); } else { spriteChanger.sprite = sprite; } } else { spriteRenderer.sprite = sprite; } currentImageName = imageName; }
private void Refresh() { if (group == null) { return; } if (index >= group.entries.Count) { image.sprite = null; return; } var sprite = image.sprite = AssetLoader.Load <Sprite>(group.entries[index].resourcePath); if (sprite != null) { image.rectTransform.sizeDelta = new Vector2(sprite.texture.width, sprite.texture.height); } else { image.rectTransform.sizeDelta = defaultImageSize; } image.rectTransform.localScale = new Vector3(scale, scale, 1.0f); indexLabel.text = $"{index + 1}/{group.entries.Count}"; scaleLabel.text = $"{scale:0.0}x"; }
public GameObject LoadTimelinePrefab(string timelinePrefabName) { if (timelinePrefabName == currentTimelinePrefabName) { return(timelinePrefab); } return(AssetLoader.Load <GameObject>(System.IO.Path.Combine(timelinePrefabFolder, timelinePrefabName))); }
public void PlayClipNo3D(string audioName, Vector3 position, float clipVolume) { if (dontPlaySound) { return; } var clip = AssetLoader.Load <AudioClip>(System.IO.Path.Combine(audioFolder, audioName)); PlayClipNo3D(clip, position, clipVolume); }
private void Refresh() { var sprite = AssetLoader.Load <Sprite>(group.entries[index].resourcePath); image.sprite = sprite; image.rectTransform.sizeDelta = new Vector2(sprite.texture.width, sprite.texture.height); float baseScale = Mathf.Max(defaultImageSize.x / sprite.texture.width, defaultImageSize.y / sprite.texture.height); image.rectTransform.localScale = new Vector3(baseScale * scale, baseScale * scale, 1.0f); }
public void SetVideo(string videoName) { if (videoName == currentVideoName) { return; } videoPlayer.clip = AssetLoader.Load <VideoClip>(System.IO.Path.Combine(videoFolder, videoName)); // TODO: how to preload video? videoPlayer.Prepare(); currentVideoName = videoName; }
public virtual void SetPrefab(string prefabName) { if (prefabName == currentPrefabName) { return; } ClearPrefab(); var prefab = AssetLoader.Load <GameObject>(System.IO.Path.Combine(prefabFolder, prefabName)); prefabInstance = Instantiate(prefab, transform); currentPrefabName = prefabName; }
public void SetTexturePath(string propertyName, string texturePath) { if (texturePath == null) { texturePath = ""; } Texture tex = null; if (texturePath != "") { tex = AssetLoader.Load <Texture>(texturePath); } base.SetTexture(propertyName, tex); textureNames[propertyName] = texturePath; }
private void UpdateText() { if (displayTexts == null) { text.text = ""; } else { text.text = I18n.__(displayTexts); } if (imageInfo != null) { // TODO: preload image.sprite = AssetLoader.Load <Sprite>(System.IO.Path.Combine(imageFolder, imageInfo.name)); image.SetNativeSize(); } }
protected virtual void SetPose(string[] poseArray, bool fade) { string poseName = PoseArrayToString(poseArray); if (poseName == currentImageName) { return; } var sprites = poseArray.Select(imageName => AssetLoader.Load <SpriteWithOffset>(System.IO.Path.Combine(imageFolder, imageName))).ToList(); var texture = characterTextureMerger.GetMergedTexture(sprites); if (fade && !gameState.isMovingBack && dialogueBoxController.state != DialogueBoxState.Skip) { textureChanger.SetTexture(texture); } else { textureChanger.InstantSet(texture); } currentImageName = poseName; }
protected void SetPose(string[] poseArray, bool fade) { string poseName = PoseArrayToString(poseArray); if (poseName == currentImageName) { return; } var sprites = poseArray.Select(imageName => AssetLoader.Load <SpriteWithOffset>(System.IO.Path.Combine(imageFolder, imageName))).ToList(); var texture = spriteMerger.GetMergedTexture(name, sprites); if (fade && !gameState.isRestoring && dialogueBoxController.state != DialogueBoxState.FastForward) { textureChanger.SetTexture(texture); } else { textureChanger.SetTextureNoFade(texture); } currentImageName = poseName; }
/// <summary> /// Show branch buttons when branch happens /// </summary> /// <param name="branchOccursData"></param> private void OnBranchHappen(BranchOccursData branchOccursData) { var branchInformations = branchOccursData.branchInformations; foreach (var branchInfo in branchInformations) { if (branchInfo.mode == BranchMode.Jump) { if (branchInfo.condition == null || branchInfo.condition.Invoke <bool>()) { gameState.SelectBranch(branchInfo.name); return; } } } if (backPanel != null) { backPanel.SetActive(true); } foreach (var branchInfo in branchInformations) { if (branchInfo.mode == BranchMode.Jump) { continue; } if (branchInfo.mode == BranchMode.Show && !branchInfo.condition.Invoke <bool>()) { continue; } var child = Instantiate(branchButtonPrefab, transform); if (branchInfo.imageInfo != null) { var layoutElement = child.AddComponent <LayoutElement>(); layoutElement.ignoreLayout = true; var image = child.GetComponent <Image>(); image.type = Image.Type.Simple; image.alphaHitTestMinimumThreshold = 0.5f; var imageInfo = branchInfo.imageInfo; // TODO: preload image.sprite = AssetLoader.Load <Sprite>(System.IO.Path.Combine(imageFolder, imageInfo.name)); image.SetNativeSize(); child.transform.localPosition = new Vector3(imageInfo.positionX, imageInfo.positionY, 0f); child.transform.localScale = new Vector3(imageInfo.scale, imageInfo.scale, 1f); } var text = child.GetComponentInChildren <Text>(); text.text = branchInfo.text; var button = child.GetComponentInChildren <Button>(); button.onClick.AddListener(() => Select(branchInfo.name)); if (branchInfo.mode == BranchMode.Enable) { button.interactable = branchInfo.condition.Invoke <bool>(); } } }