SHOW:
|
|
- or go back to the newest paste.
| 1 | using System.Collections; | |
| 2 | using System.IO; | |
| 3 | using UnityEditor; | |
| 4 | using UnityEngine; | |
| 5 | ||
| 6 | - | public class Synchronize : EditorWindow {
|
| 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; |
| 12 | + | isPositive = false; |
| 13 | - | path=""; |
| 13 | + | path = string.Empty; |
| 14 | } | |
| 15 | ||
| 16 | - | string [] pA = Application.dataPath.Split('/');
|
| 16 | + | string[] appPath = Application.dataPath.Split('/');
|
| 17 | - | static string path=""; |
| 17 | + | static string path = string.Empty; |
| 18 | - | string [] client2; |
| 18 | + | string[] client2; |
| 19 | - | static bool ye; |
| 19 | + | static bool isPositive; |
| 20 | - | string fileS=""; |
| 20 | + | string fileS = string.Empty; |
| 21 | - | string pathS = Application.dataPath+"/UMK_Files/NPCfile.umk"; |
| 21 | + | string pathS = Application.dataPath + "/UMK_Files/NPCfile.umk"; |
| 22 | - | bool on; |
| 22 | + | bool isOn; |
| 23 | ||
| 24 | - | void OnGUI(){
|
| 24 | + | void OnGUI() |
| 25 | - | if(!ye){
|
| 25 | + | |
| 26 | - | for(int i=0;i<pA.Length-3;i++){
|
| 26 | + | if(!isPositive) |
| 27 | - | path=path+pA[i]+"/"; |
| 27 | + | {
|
| 28 | for(int i = 0; i < appPath.Length - 3; i++) | |
| 29 | - | ye=true; |
| 29 | + | {
|
| 30 | path += appPath[i] + "/"; | |
| 31 | } | |
| 32 | - | if(GUILayout.Button("Synchronize NPCs",GUILayout.Width(350),GUILayout.Height(40))){
|
| 32 | + | |
| 33 | - | client2 = Directory.GetFiles(path,"NPCfileC.umk",SearchOption.AllDirectories); |
| 33 | + | isPositive = true; |
| 34 | - | on=true; |
| 34 | + | |
| 35 | - | if(client2.Length>0){
|
| 35 | + | |
| 36 | - | on=false; |
| 36 | + | |
| 37 | - | fileS=client2[0]; |
| 37 | + | if(GUILayout.Button("Synchronize NPCs", GUILayout.Width(350), GUILayout.Height(40)))
|
| 38 | {
| |
| 39 | - | using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS)) |
| 39 | + | client2 = Directory.GetFiles(path, "NPCfileC.umk", SearchOption.AllDirectories); |
| 40 | - | {
|
| 40 | + | isOn = true; |
| 41 | - | str1 = reader.ReadToEnd(); |
| 41 | + | if(client2.Length > 0) |
| 42 | - | } |
| 42 | + | {
|
| 43 | - | using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileS)) |
| 43 | + | isOn = false; |
| 44 | - | {
|
| 44 | + | fileS = client2[0]; |
| 45 | - | |
| 45 | + | |
| 46 | - | file.Write(str1); |
| 46 | + | |
| 47 | - | } |
| 47 | + | using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS)) |
| 48 | {
| |
| 49 | str1 = reader.ReadToEnd(); | |
| 50 | - | if(client2!=null){
|
| 50 | + | } |
| 51 | - | if(client2.Length==0 && on){
|
| 51 | + | |
| 52 | - | GUILayout.Label("Set the NPC Editor in the Client's Project firstly!",EditorStyles.boldLabel);
|
| 52 | + | using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileS)) |
| 53 | {
| |
| 54 | file.Write(str1); | |
| 55 | } | |
| 56 | } | |
| 57 | } | |
| 58 | ||
| 59 | if(client2 != null) | |
| 60 | {
| |
| 61 | if(client2.Length == 0 && isOn) | |
| 62 | {
| |
| 63 | GUILayout.Label("Set the NPC Editor in the Client's Project firstly!", EditorStyles.boldLabel);
| |
| 64 | } | |
| 65 | } | |
| 66 | } | |
| 67 | } |