IEnumerator RadialMenuAnimation(float speed, Dictionary <int, AssetInteraction> cells) { if (speed > 0) { menuOpen = true; RadialMenu.SetActive(true); foreach (int i in cells.Keys) { GameObject option = RadialMenu.transform.GetChild(i).gameObject; option.SetActive(true); AssetInteraction AI = option.GetComponent <AssetInteraction>(); //AI.Setup(cells[i]); } menuAnim["OpenMenu"].speed = speed; menuAnim.Play("OpenMenu"); } else { menuAnim["OpenMenu"].speed = speed; menuAnim["OpenMenu"].time = menuAnim["OpenMenu"].length; menuAnim.Play("OpenMenu"); yield return(new WaitForSeconds(menuAnim["OpenMenu"].length)); foreach (Transform child in RadialMenu.transform) { child.gameObject.SetActive(false); } RadialMenu.SetActive(false); menuOpen = false; } }
private void Update() { CheckInteractions(); if (Input.GetKeyDown(KeyCode.Tab) && InteractObject != null && movementEnabled) { AssetInteraction ai = InteractObject.GetComponentInChildren <InteractionMenu>().options[0]; ai.Activate(interactable, player); } CalculateMovement(); }
private void ImportAssetInteractions(string ModPath) { DirectoryInfo dir = new DirectoryInfo(ModPath + "/AssetInteractions"); FileInfo[] files = dir.GetFiles("*.json", SearchOption.AllDirectories); foreach (FileInfo file in files) { //JSON string json = File.ReadAllText(file.FullName); JToken jObject = JToken.Parse(json); //Name string name = "New AssetInteration"; if (jObject["Name"] != null) { name = jObject["Name"].ToObject <string>(); } //Sprite GameObject sprite = null; string spriteName = "UNDEFINED"; if (jObject["Sprite"] != null) { spriteName = jObject["Sprite"].ToObject <string>(); } if (spriteName != "UNDEFINED") { Sprites.TryGetValue(spriteName, out sprite); } if (sprite == null) { sprite = defaultSprite; } //Create 'prefab' ///Create AssetInteraction with sprite copy as child GameObject prefab = new GameObject(name); prefab.transform.SetParent(PrefabHolder); GameObject assetSprite = Instantiate(sprite, prefab.transform); assetSprite.name = "Sprite"; assetSprite.transform.position = new Vector3(0f, 0f, 0f); SpriteRenderer renderer = assetSprite.GetComponentInChildren <SpriteRenderer>(); renderer.sortingLayerName = "Popups"; renderer.sortingOrder = 1; renderer.gameObject.layer = 5; //Create AssetInteraction AssetInteraction AI = new AssetInteraction(name, prefab); AssetInteractions.Add(name, AI); } }