Unity Save/Load sistemi

0 oy
225 gösterim
9 Temmuz 2022 Yazılım kategorisinde Altarka Studio (123 puan) sordu
Unity2D save/Load sistemi

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;

public class scriptin ismi : MonoBehaviour
{
   public float x;
   public float y;
    void Start()
    {
        if (File.Exists(@"C:\Users\90505\Desktop\4ağustos\save.txt"))
        {
            FileStream fs = File.OpenRead(@"C: \save.txt");
            StreamReader sr = new StreamReader(fs);
            float konumumX = float.Parse(sr.ReadLine());
            float konumumY = float.Parse(sr.ReadToEnd());

            transform.position = new Vector2(konumumX, konumumY);
            Debug.Log(konumumY);
            Debug.Log(konumumX);
            sr.Close();
            fs.Close();
        }
        else
        {
            FileStream fs = File.Create(@"C:\Users\90505\Desktop\4ağustos\save.txt");

            fs.Close();
        }
        
    }
    private void Update()
    {
      
        

    }
    // Update is called once per frame
    private void OnTriggerStay2D(Collider2D collision)
    {
            if(collision.gameObject.tag == "save")
        {
            if (File.Exists(@"save dosyasının yolu"))
            {
                FileStream fs = File.OpenWrite(@"C: \savedosyasının ismi.txt");
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(transform.position.x);
                sw.Write(transform.position.y);

                sw.Close();
                fs.Close();
            }
            else
            {
                FileStream fs = File.Create(@"save dosyasının yolu");

                fs.Close();
            }
        }
    }
}

2 Cevap

0 oy
14 Mart jonemartin (12 puan) cevapladı

If you are beginner and didn't know how to safe/load unity file, you must Learn here how to save and load a game in Unity using PlayerPrefs, Serialization and JSON. Complete your user's experience by allowing them to save.

Professional Bookkeeping Services in USA

0 oy
15 Mart footballi (2 puan) cevapladı

سایت اصلی وان ایکس بت  is an online sports betting platform that has been in operation since 2007. The platform offers users the ability to bet on a wide range of sports and events, including football, basketball, tennis, cricket, and many others. In addition to sports betting, 1xBet also offers a variety of casino games, virtual sports, and e-sports.

Hoş geldiniz, Oyunundibi sizlere sorularınızın diğer üyelerimiz tarafından cevaplanması için bir ortam sağlar.

Görüş ve önerilerinizi İletişim sayfası üzerinden gönderebilirsiniz.

Steam Grubumuza katılmayı unutmayın!



...