Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class LoadProfiles : MonoBehaviour
- {
- public int ProfileID;
- public int ProfileImage;
- public string ProfileName;
- public string CompanyName;
- //For UI
- public GameObject ProfilesUI;
- public GameObject wheretomaketheprofileUI;
- GameObject ProfilesUIClone;
- public Text Name;
- public Text Company;
- public Image img;
- //List for saving so you can save more.
- static List<ProfileData> profileData = new List<ProfileData>();
- public void Start()
- {
- if(profileData == null)
- {
- Debug.Log("You got no profiles created!");
- //SceneManager.LoadScene("CreateProfile");
- profileData = new List<ProfileData>();
- }
- else
- {
- if (!System.IO.Directory.Exists(Application.persistentDataPath + "/Profiles"))
- {
- System.IO.Directory.CreateDirectory(Application.persistentDataPath + "/Profiles");
- }
- if (!System.IO.File.Exists(Application.persistentDataPath + "/Profiles/profiles.dat"))
- {
- System.IO.File.Create(Application.persistentDataPath + "/Profiles/profiles.dat");
- }
- profileData = SaveProfile.LoadProfiles();
- for (int i = 0; i < profileData.Count; i++)
- {
- ProfileName = profileData[i].profileName;
- CompanyName = profileData[i].companyName;
- ProfileImage = profileData[i].profileImage;
- ProfileID = profileData[i].profileID;
- ProfilesUIClone = Instantiate(ProfilesUI) as GameObject;
- ProfilesUIClone.transform.SetParent(wheretomaketheprofileUI.transform.parent);
- Name = ProfilesUIClone.transform.Find("Name").GetComponentInChildren<Text>();
- Company = ProfilesUIClone.transform.Find("Company").GetComponentInChildren<Text>();
- Name.text = ProfileName;
- Company.text = CompanyName;
- ProfilesUIClone.SetActive(true);
- if (ProfileImage == 0)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage1").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- else if (ProfileImage == 1)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage2").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- else if (ProfileImage == 2)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage3").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- }
- }
- /*ProfilesUIClone = Instantiate(ProfilesUI) as GameObject;
- ProfilesUIClone.transform.SetParent(wheretomaketheprofileUI.transform.parent);
- Name = ProfilesUIClone.transform.Find("Name").GetComponentInChildren<Text>();
- Company = ProfilesUIClone.transform.Find("Company").GetComponentInChildren<Text>();
- Name.text = ProfileName;
- Company.text = CompanyName;
- ProfilesUIClone.SetActive(true);
- if (ProfileImage == 0)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage1").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- else if (ProfileImage == 1)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage2").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- else if (ProfileImage == 2)
- {
- img = ProfilesUIClone.transform.Find("ProfileImage3").GetComponent<Image>();
- img.gameObject.SetActive(true);
- }
- */}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement