Save a script to HDD


How would I save a script from my character to somewhere on my harddrive (C:/games/) when I click on a GUI button?

So to explain a bit more - When I click the GUI button(<- GUI script is on my character) it will find another script on my character(<- charInfo) and save a copy of it to C:/games/

Is it even possible?

Logically the way you do this is get the script you want to save and write it to the hard drive :slight_smile:
Very easy, but you have to how you can technically do this. Unfortunately i never wrote a line of code in Java script, but i don’t think it will be a big deal for you to translate the code.

using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

public class ScriptSaver : MonoBehaviour
    private void Update()
        if (Input.GetKeyDown(KeyCode.S))


    private void SaveScript()
        // Open a stream to the current script for example.
        // Of course you can change the string to whatever script you want to save in your project
        StreamReader streamReader = new StreamReader(@"C:\DEV\Demo Project\Assets\ScriptSaver.cs");
        // Write it where you want it
        StreamWriter streamWriter = new StreamWriter(@"C:\Saved.cs");

        while (streamReader.EndOfStream == false)

        // Dont forget to close your streams