Guest User

syncnpc

a guest
Mar 10th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. using System.IO;
  5.  
  6. public class Synchronize : EditorWindow {
  7.  
  8.     [MenuItem("Ultimate MMORPG Kit/Synchronize NPC")]
  9.     public static void ShowWindow()
  10.     {
  11.         EditorWindow.GetWindow(typeof(Synchronize));
  12.         ye=false;
  13.         path="";
  14.     }
  15.    
  16.     string [] pA = Application.dataPath.Split('/');
  17.     static string path="";
  18.     string [] client2;
  19.     static bool ye;
  20.     string fileS="";
  21.     string pathS = Application.dataPath+"/UMK_Files/NPCfile.umk";
  22.     bool on;
  23.    
  24.     void OnGUI(){
  25.         if(!ye){
  26.             for(int i=0;i<pA.Length-3;i++){
  27.                 path=path+pA[i]+"/";   
  28.             }
  29.             ye=true;
  30.         }
  31.         GUILayout.Space(10);
  32.         if(GUILayout.Button("Synchronize NPCs",GUILayout.Width(350),GUILayout.Height(40))){
  33.             client2 = Directory.GetFiles(path,"NPCfileC.umk",SearchOption.AllDirectories);
  34.             on=true;
  35.             if(client2.Length>0){
  36.                 on=false;
  37.                 fileS=client2[0];
  38.                 string str1;
  39.                                 using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS))
  40.                                 {
  41.                                     str1 = reader.ReadToEnd();
  42.                                 }
  43.                                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileS))
  44.                                  {
  45.                                    
  46.                                     file.Write(str1);
  47.                                  }
  48.             }
  49.         }
  50.         if(client2!=null){
  51.             if(client2.Length==0 && on){
  52.                 GUILayout.Label("Set the NPC Editor in the Client's Project firstly!",EditorStyles.boldLabel);     
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment