- Home /
cant get if (String.Equals(magicsetom[x], boxadd)) working
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class hudmager : MonoBehaviour
{
private GameObject[] magicbox;
private string[] magicsetom;
private string[] MagicNameloder;
[SerializeField] private string boxadd;
private bool startmagic;
[SerializeField]private GameObject image,player;
private float number=0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
MagicNameloder = this.GetComponent<texttomagic>().MagicName;
magicsetom = this.GetComponent<texttomagic>().magicList;
magicbox = GameObject.FindGameObjectsWithTag("magicbox");
for (int i = 0; i < magicbox.Length; i++)
{
if (magicbox[i].GetComponent<hithandstest>().hit == true)
{
if (number < 42)
{
boxadd +=""+ magicbox[i].transform.parent.name +"_" + magicbox[i].name+"/";
startmagic = true;
number += 1;
}
else
{
startmagic = false;
}
}
if (startmagic==false)
{
boxadd = "";
number = 0;
}
}
for (int x = 0; x < magicsetom.Length; x++)
{
if (boxadd !="")
{
if (x % 2 != 0)
{
if (String.Equals(magicsetom[x], boxadd))
{
Debug.Log("" + magicsetom[x] + "==" + "" + boxadd+"runing");
Instantiate(Resources.Load("Magic/" + MagicNameloder[x + 1]), player.transform.position, Quaternion.identity);
}
else if (String.Equals(magicsetom[x] , boxadd))
{
// Debug.Log("" + magicsetom[x] + "!=" + "" + boxadd);
}
}
}
}
if (!image.activeSelf)
{
boxadd = "";
number = 0;
}
}
}
------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Linq;
using System.Data;
using System;
public class texttomagic : MonoBehaviour
{
public static List<string> textArray;
private TextAsset txtAsset;
[HideInInspector]
public string[] magicList;
[HideInInspector]
public string[] MagicName;
[SerializeField]
private int[] RowstoReadfrom;
// Start is called before the first frame update
void Start()
{
txtAsset = (TextAsset)Resources.Load("code/maigc");
readTextFile();
}
// Update is called once per frame
void Update()
{
}
void readTextFile()
{
textArray = txtAsset.text.Split('\n').ToList();
for (int i = 0; i < RowstoReadfrom.Length; i++)
{
if (RowstoReadfrom[0] < 0 || RowstoReadfrom.Length == 0)
{
magicList[0] = txtAsset.text;
}
else
{
if (i % 2 != 0)
{
magicList[i] = textArray[RowstoReadfrom[i]] + "\n";
}
else
{
MagicName[i] = textArray[RowstoReadfrom[i]] + "\n";
}
}
}
}
}
------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class hithandstest : MonoBehaviour
{
GameObject hud;
public bool hit = false;
public string myname;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
hud = GameObject.FindGameObjectWithTag("hud");
}
void OnTriggerStay(Collider other)
{
if (other.tag == "Player")
{
if (OVRInput.GetDown(OVRInput.Button.One))
{
myname = other.name;
hit = true;
}
else
{
hit = false;
}
}
}
void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
myname = "";
hit = false;
}
}
}
------------------------------------------------------------------------------------------------------------
this is 0
B_M/
Magic Missile
B_M/Y_R/B_L/B_M/
name
B_U/B_U/B_D/B_D/B_L/B_R/B_L/B_R/G_M/R_M/B_M/
bryce
Comment
ok, I found out what wrong but don't know who to fix it fists it has hides letter magicsetom[x] so if you look magicsetom[1].Length is 6, not 4 so even if you keep that in $$anonymous$$d it still does not work so never use text in a string if some can find out what were I went wrong plz let me know thanks
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Ui text to string ? 1 Answer
Distribute terrain in zones 3 Answers