What I want to do is like applying https://www.sejuku.net/blog/55029 and
We are trying to implement the MyExplanation variable content of an Item script set in a separate script by calling the SetExplanation function of ExplanationTXT when EditSlot OnDrop is run.
Error Present (Image)
Import Data
using System.Collections;
using System.Collections.General;
using UnityEngine;
using UnityEngine.UI;
CreateAssetMenu(fileName="Items", menuName="Items/items")]
public class item —ScriptableObject
{
SerializeField
private string itemName;
SerializeField
private Sprite itemImage;
SerializeField
private text expansion
privateEditButton.SymbolEditSymbol;
public string MyItemName {get=>itemName;}
public Sprite MyItemImage {get=>itemImage;}
public Text MyExplanation {get=>explanation;}
}
Script with ONDROP function when to call
using System.Collections;
using System.Collections.General;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class EditSlot —Slot
{
private edit;
private text;
privateExplanationTXT expansionTXT;
public Edit MyEdit {get=>edit;private set=>edit=value;}
public Text MyText {get=>text;private set=>text=value;}
publicExplanationTXTExplanationTXT {get=>explanationTXT;private set=>explanationTXT=value;}
protected override void Start()
{
base.Start(); // Inherited start function
MyEdit=FindObjectOfType<Edit>();
MyText=FindObjectOfType<Text>();
}
public override void OnDrop (PointerEventData eventData)
{
base.OnDrop(eventData);
edit.SetItem(MyItem);
ExplanationTXT.SetExplanation (MyText);call here
}
}
SetExplanation Action
using System.Collections;
using System.Collections.General;
# if UNITY_EDITOR
using UnityEngine;
using UnityEngine.UI;
public classExplanationTXT—MonoBehavior
{
private item;
private TextChangeTxtObj=null;
public Item MyItem {get=>item;private set=>item=value;}
public Text MyChangeTxtObj {get=>ChangeTxtObj;private set=>ChangeTxtObj=value;}
public void SetExplanation (Text text)
{
TextChangeTxt=MyChangeTxtObj.GetComponent<Text>();Call empty TEXT on ChangeTXT
MyChangeTxtObj.text=MyItem.MyExplanation; Storing MyItem.MyExplanation for Objects from Called
}
}
#endif
But there's an error: you can't implicitly convert the UNUTY ENGINE UI to STRING. All the variables you create in the ITEM class are TEXT and you shouldn't be using STRING, but you get this error.
MyItem.MyExplanation.text;
Can't we?
© 2024 OneMinuteCode. All rights reserved.