Unity Save/Load sistemi

0 oy
398 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();
            }
        }
    }
}

4 Cevap

0 oy
14 Mart jonemartin (14 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.

0 oy
5 Temmuz moz1 (42 puan) cevapladı

Play and easy to break,  918kiss  direct web slots, we here all players can be confident that all online games are imported for sure. Because all of these 100 online web games with the slots website here are all online games that are quite interested, ranked in the top ranks in Google, no need to waste time playing anymore.

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!



301 soru

211 cevap

38 yorum

2,757,777 üye

66 Online Users
0 Member 66 Guest
Today Visits : 11489
Yesterday Visits : 20881
Total Visits : 26179188
...