// TODO: make redundant /// <summary> /// Loads a Torii object (3D model with animations) and returns a gameobject /// </summary> public static GameObject LoadObject(string filePath, bool collisionMesh, ResourceLifespan lifespan) { GameObject g = UnityEngine.Object.Instantiate(ResourceManager.Load <GameObject>(filePath, lifespan)); TOBJ t = g.GetComponent <ToriiObject>().ToriiObj; Renderer[] renderers = g.GetComponentsInChildren <Renderer>(); foreach (Renderer r in renderers) { Material m = r.material; // load texture if (!string.IsNullOrEmpty(t.ObjectTexture)) { if (Path.GetFileNameWithoutExtension(t.ObjectTexture).Contains("[")) { // part of a texture set m.shader = Shader.Find(GameSettings.CurrentSettings.UseClassicShaders ? "LSD/PSX/TransparentSet" : "LSD/TransparentSet"); string texNameWithoutExtension = Path.GetFileNameWithoutExtension(t.ObjectTexture); string baseTexName = texNameWithoutExtension.Substring(1); string pathToTextureDir = Path.GetDirectoryName(t.ObjectTexture); m.SetTexture("_MainTexA", ResourceManager.Load <Texture2D>(PathCombine(pathToTextureDir, "A" + baseTexName) + ".png", lifespan)); m.SetTexture("_MainTexB", ResourceManager.Load <Texture2D>(PathCombine(pathToTextureDir, "B" + baseTexName) + ".png", lifespan)); m.SetTexture("_MainTexC", ResourceManager.Load <Texture2D>(PathCombine(pathToTextureDir, "C" + baseTexName) + ".png", lifespan)); m.SetTexture("_MainTexD", ResourceManager.Load <Texture2D>(PathCombine(pathToTextureDir, "D" + baseTexName) + ".png", lifespan)); } else { m.shader = Shader.Find(GameSettings.CurrentSettings.UseClassicShaders ? "LSD/PSX/Transparent" : "Transparent/Diffuse"); m.SetTexture("_MainTex", ResourceManager.Load <Texture2D>(t.ObjectTexture, lifespan)); } } } // load animations if (t.NumberOfAnimations > 0) { ToriiObjectAnimator animator = g.AddComponent <ToriiObjectAnimator>(); foreach (Transform child in g.transform) { animator.Objects.Add(child.gameObject); } animator.ToriiObject = t; } if (collisionMesh) { foreach (Transform child in g.transform) { child.gameObject.AddComponent <MeshCollider>(); } } g.transform.localScale = new Vector3(-g.transform.localScale.x, g.transform.localScale.y, g.transform.localScale.z); g.SetActive(true); return(g); }
public override IEnumerator DoAction() { ToriiObjectAnimator animator = ReferencedSequence.ReferencedGameObject.GetComponentInChildren <ToriiObjectAnimator>(); animator.ChangeAnimation(AnimationName); animator.Play(); ReferencedSequence.DoNextAction(); yield return(null); }