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