Forum rules - please read before posting.

Inventory "Properties" Types

2»

Comments

  • It's a little difficult to tell without knowing when you're clicking, but I don't see any drag-drop issues in the video now. The main issue seems to be the green square showing up.

    You've changed the Appear type to On Hotspot now - so you'll need to use the script that shows when mouse-overing items, not when an item is selected.

    If you want the inventory graphic to show at all times (i.e. when hovered over and when selected), that would need a new script that's a combination of both.

  • Yesss. after doing what you lately said, the main problem was just that while drag.drop/ The informative UI Menu shows up that Rawimage green frame instead of just hiding away.
    Yes yes . i use The Script with Mouse over. yes i did that. ofcourse.

    Here i say what i want....
    -My inventory UI comes when the user presses E key.
    - The user can get some info when mouse-over each item in Inventory. It is why i wanted the inventory Info UI (I called it "ItemDesc" UI) to be called on mouse over.

    After mouse over, the user might need to drag drop the item to the craft menu or to a hotspot in scene.
    In this case i expected the Informative menu(Itemdesc) to go/hide away when item is selected or drag/dropped.

  • If you want it to show when hovering over an item, but not when an item is selected, it's best to rely on script for the whole behaviour. You can also update the description text box in the same script - no need to rely on Menu Elements.

    Try this:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class ImageItemPropertyUI : MonoBehaviour
    {
    
        public string imagePropertyName = "Image";
        public string descriptionPropertyName = "DescriptionText";
        public RawImage rawImage;
        public Text descriptionText;
        public CanvasGroup canvasGroup;
    
        private void Update ()
        {
            if (!InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance) &&
                 InvInstance.IsValid (KickStarter.runtimeInventory.HoverInstance))
            {
                Object imageOb = KickStarter.runtimeInventory.HoverInstance.GetProperty (imagePropertyName).UnityObjectValue;
                if (imageOb)
                {
                    Texture2D texture = (Texture2D) imageOb;
                    rawImage.texture = texture;
                    rawImage.enabled = true;
                }
                else
                {
                    rawImage.enabled = false;
                }
    
                descriptionText.text = KickStarter.runtimeInventory.HoverInstance.GetProperty (descriptionPropertyName).TextValue;
                canvasGroup.alpha = 1f;
                return;
            }
    
            canvasGroup.alpha = 0f;
        }
    
    }
    

    Don't use the Menu Manager for the moment. Attach this to a copy of the UI prefab that's in the scene, and lock/delete your current Description menu. Assign the fields in the Inspector. It can be re-incorporated back into the Menu Manager later if you wish, but first make sure that the behaviour is correct.

  • edited June 2022

    Thanks . Going to Do it, right now. <3 <3 <3

  • Sorry to say it does not work. :(
    I removed Description menu from Menu manager.
    Then Openned UI prefab and Assigned the Script to it. hooked the Canvas Objects to the public fields and tested couple of times ...
    Video :
    https://rumble.com/v17q5t5-inventorypropertiesui.html

  • After removing the Menu from the Menu Manager, the UI prefab will no longer be automatically spawned in at runtime - you must place the prefab inside the scene Hierarchy.

  • Thank You. It works perfectly. :p
    So i just need to Add this UI to all my next scenes.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.