Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

ok guys im having a mild issue with file sync script

unity3d c# sync

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Noct

Noct

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 31 October 2014 - 10:49 PM

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;

public class Synchronize : EditorWindow {

	[MenuItem("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 = "C:/Users/malform/Documents/Ultimate MMORPG Server/Assets/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("C:/dev/desolateclient/Assets/UMK_Files/NPCfileC.umk");
			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);		
			}
		}
	}
}

the code is suppost to take the server side file copy it send it to the client project and rename it to NPCfileC.umk  altho the client file isnt being modified or changed and unsure why.



#2 Noct

Noct

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 03 November 2014 - 11:59 PM

97 views and no replys hmmm something is very wrong with that as this problem isnt that hard im just unsure if my formatting is correct for the function






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download