Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.IO;
- using UnityEditor;
- using UnityEngine;
- public class Synchronize : EditorWindow
- {
- [MenuItem("Ultimate MMORPG Kit/Synchronize NPC")]
- public static void ShowWindow()
- {
- EditorWindow.GetWindow(typeof(Synchronize));
- isPositive = false;
- path = string.Empty;
- }
- string[] appPath = Application.dataPath.Split('/');
- static string path = string.Empty;
- string[] client2;
- static bool isPositive;
- string fileS = string.Empty;
- string pathS = Application.dataPath + "/UMK_Files/NPCfile.umk";
- bool isOn;
- void OnGUI()
- {
- if(!isPositive)
- {
- for(int i = 0; i < appPath.Length - 3; i++)
- {
- path += appPath[i] + "/";
- }
- isPositive = true;
- }
- GUILayout.Space(10);
- if(GUILayout.Button("Synchronize NPCs", GUILayout.Width(350), GUILayout.Height(40)))
- {
- client2 = Directory.GetFiles(path, "NPCfileC.umk", SearchOption.AllDirectories);
- isOn = true;
- if(client2.Length > 0)
- {
- isOn = false;
- fileS = client2[0];
- string str1;
- using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS))
- {
- str1 = reader.ReadToEnd();
- }
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileS))
- {
- file.Write(str1);
- }
- }
- }
- if(client2 != null)
- {
- if(client2.Length == 0 && isOn)
- {
- GUILayout.Label("Set the NPC Editor in the Client's Project firstly!", EditorStyles.boldLabel);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment