hi so quick overview - i have a turn based RPG type game and this script is handling where units are placed on a sort of game board, the board itself is a someone of a chessboard with each square being its own game object and a node. my nodes are contained in an array.
i have it so that when a button is pressed the unit names and positions are saved to an SQL server so they can be loaded in a game match
what i am having trouble doing is translating the “placeholder” game object to string so it can be saved to my SQL server
any help would be appreciated, or if anyone has a better way of doing this i always welcome feedback
-links/samples&tuts are always apreciated
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LayoutManager : MonoBehaviour
{
string CreateLayoutURL = "localhost/tactics_arena/insertunitpos.php";
public Image singleTile;
public GameObject[] placeholders;
public string inputUnitname;
public string inputUnitposition;
void Update()
{
foreach(GameObject go in placeholders)
{
Image image = go.GetComponent<Image> ();
if (image != null && image.sprite.name == "ArcherCube")
{
//Debug.Log ("Found Archer");
Debug.Log(go);
inputUnitname = "Archer";
//inputUnitposition = ??????
}
if(image != null && image.sprite.name == "KnightCube")
{
Debug.Log (go);
}
}
}
public void SavePlayerLayout()
{
CreateLayout (inputUnitname, inputUnitposition);
}
public void CreateLayout(string unitname, string unitposition)
{
WWWForm form = new WWWForm ();
form.AddField ("unitNamePost", unitname);
form.AddField ("unitPosPost", unitposition);
WWW www = new WWW (CreateLayoutURL, form);
}
}