Ejemplo n.º 1
0
		public static Dictionary<string,EventProxyFileDetails> FindFiles()
		{
			
			//Lookup enums in file names
			Dictionary<string,EventProxyFileDetails> detailsList = new Dictionary<string,EventProxyFileDetails>();
			
			classFiles = new List<string>();
			FindAllCSharpScriptFiles(Application.dataPath);
			
			//Lookup class name in the class file text 
			for (int i = 0; i < classFiles.Count; i++)
			{
				string filePath = classFiles[i];
				string codeFile = File.ReadAllText(filePath);

				if (codeFile.Contains("__"+"PLAYMAKER_EVENT_PROXY__")) // compose the tag to avoid this file to be found...
				{
					FileInfo _info = new FileInfo(filePath);

					string fileName = _info.Name;

					string className = "";
					Match _classNameMatch = Regex.Match(codeFile,@"(?:public(?:\s+)class(?:\s+))(\w+)(?:\s+)(?::)");
					if (_classNameMatch.Success)
					{
						className = _classNameMatch.Groups[1].Value;
					}

					string nameSpace = "";
					Match _nameSpaceMatch = Regex.Match(codeFile,@"namespace (\w.+)");
					if (_nameSpaceMatch.Success)
					{
						nameSpace = _nameSpaceMatch.Groups[1].Value;
					}

					string methodName = "";
					Match methodNameMatch = Regex.Match(codeFile,@"public(?:\s+)void(?:\s+)(\w+)");
					if (methodNameMatch.Success)
					{
						methodName = methodNameMatch.Groups[1].Value;
					}


					EventProxyFileDetails _details = new EventProxyFileDetails(
						className, 
						nameSpace,
						methodName,
						fileName,
						filePath, 
						_info.LastWriteTimeUtc
						);

					detailsList.Add (filePath,_details);

				}

			}

			return detailsList;
		}
Ejemplo n.º 2
0
        public static Dictionary <string, EventProxyFileDetails> FindFiles()
        {
            //Lookup enums in file names
            Dictionary <string, EventProxyFileDetails> detailsList = new Dictionary <string, EventProxyFileDetails>();

            classFiles = new List <string>();
            FindAllCSharpScriptFiles(Application.dataPath);

            //Lookup class name in the class file text
            for (int i = 0; i < classFiles.Count; i++)
            {
                string filePath = classFiles[i];
                string codeFile = File.ReadAllText(filePath);

                if (codeFile.Contains("__" + "PLAYMAKER_EVENT_PROXY__"))               // compose the tag to avoid this file to be found...
                {
                    FileInfo _info = new FileInfo(filePath);

                    string fileName = _info.Name;

                    string className       = "";
                    Match  _classNameMatch = Regex.Match(codeFile, @"(?:public(?:\s+)class(?:\s+))(\w+)(?:\s+)(?::)");
                    if (_classNameMatch.Success)
                    {
                        className = _classNameMatch.Groups[1].Value;
                    }

                    string nameSpace       = "";
                    Match  _nameSpaceMatch = Regex.Match(codeFile, @"namespace (\w.+)");
                    if (_nameSpaceMatch.Success)
                    {
                        nameSpace = _nameSpaceMatch.Groups[1].Value;
                    }

                    string methodName      = "";
                    Match  methodNameMatch = Regex.Match(codeFile, @"public(?:\s+)void(?:\s+)(\w+)");
                    if (methodNameMatch.Success)
                    {
                        methodName = methodNameMatch.Groups[1].Value;
                    }


                    EventProxyFileDetails _details = new EventProxyFileDetails(
                        className,
                        nameSpace,
                        methodName,
                        fileName,
                        filePath,
                        _info.LastWriteTimeUtc
                        );

                    detailsList.Add(filePath, _details);
                }
            }

            return(detailsList);
        }
Ejemplo n.º 3
0
        public static Dictionary <string, EventProxyFileDetails> FindFiles()
        {
            //Lookup enums in file names
            Dictionary <string, EventProxyFileDetails> detailsList = new Dictionary <string, EventProxyFileDetails>();

            classFiles = new List <string>();
            FindAllCSharpScriptFiles(Application.dataPath);

            //Lookup class name in the class file text
            for (int i = 0; i < classFiles.Count; i++)
            {
                string filePath = classFiles[i];
                string codeFile = File.ReadAllText(filePath);

                if (codeFile.Contains("__" + "PLAYMAKER_EVENT_PROXY__"))               // compose the tag to avoid this file to be found...
                {
                    FileInfo _info = new FileInfo(filePath);

                    string fileName = _info.Name;

                    string className       = "";
                    Match  _classNameMatch = Regex.Match(codeFile, @"(?:public(?:\s+)class(?:\s+))(\w+)(?:\s+)(?::)");
                    if (_classNameMatch.Success)
                    {
                        className = _classNameMatch.Groups[1].Value;
                    }

                    string nameSpace       = "";
                    Match  _nameSpaceMatch = Regex.Match(codeFile, @"namespace (\w.+)");
                    if (_nameSpaceMatch.Success)
                    {
                        nameSpace = _nameSpaceMatch.Groups[1].Value;
                    }

                    string methodName      = "";
                    Match  methodNameMatch = Regex.Match(codeFile, @"public(?:\s+)void(?:\s+)(\w+)");
                    if (methodNameMatch.Success)
                    {
                        methodName = methodNameMatch.Groups[1].Value;
                    }

                    PlayMakerEventProxyCreator.ParameterType methodParamType = PlayMakerEventProxyCreator.ParameterType.none;
                    Match methodParamTypeMatch = Regex.Match(codeFile, @"\((\w*) parameter\)");
                    if (methodParamTypeMatch.Success)
                    {
                        string _type = methodParamTypeMatch.Groups[1].Value;

                        switch (_type)
                        {
                        case "float":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Float;
                            break;

                        case "int":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Int;
                            break;

                        case "bool":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Bool;
                            break;

                        case "GameObject":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.GameObject;
                            break;

                        case "String":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.String;
                            break;

                        case "Vector2":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Vector2;
                            break;

                        case "Vector3":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Vector3;
                            break;

                        case "Color":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Color;
                            break;

                        case "Rect":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Rect;
                            break;

                        case "Material":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Material;
                            break;

                        case "Texture":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Texture;
                            break;

                        case "Quaternion":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Quaternion;
                            break;

                        case "Object":
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.Object;
                            break;

                        default:
                            methodParamType = PlayMakerEventProxyCreator.ParameterType.none;
                            break;
                        }
                    }


                    EventProxyFileDetails _details = new EventProxyFileDetails(
                        className,
                        nameSpace,
                        methodName,
                        methodParamType,
                        fileName,
                        filePath,
                        _info.LastWriteTimeUtc
                        );

                    detailsList.Add(filePath, _details);
                }
            }

            return(detailsList);
        }
		void StartEditingExistingProxy(EventProxyFileDetails details)
		{

			currentDefinition.FolderPath = details.projectPath.Substring(0,details.projectPath.Length -(details.className.Length+3));
			currentDefinition.Name = details.className;
			currentDefinition.PublicMethodName = details.methodName;
			currentDefinition.NameSpace = details.nameSpace;

			_currentFileDetails = details;
		}
		void OnGUI_DoEditableEnumItem(string filePath,EventProxyFileDetails details)
		{
			bool _isCurrentlyEdited = (currentDefinition.FolderPath+currentDefinition.Name+".cs").Equals(details.projectPath);
			// check if this is the item we are currently editing
			if (_isCurrentlyEdited)
			{
				_currentFileDetails = details;
				GUI.color = Color.green;
			}
			GUILayout.BeginHorizontal("box",GUILayout.ExpandHeight(false));

			GUI.color = Color.white;

			GUILayout.Label(details.nameSpace+"."+details.methodName);
			
			GUILayout.FlexibleSpace();
			
			if (GUILayout.Button("Select in Project","MiniButton"))
			{
				var _object = AssetDatabase.LoadAssetAtPath("Assets/"+details.projectPath,typeof(UnityEngine.Object));
				
				EditorGUIUtility.PingObject(_object.GetInstanceID());
				Selection.activeInstanceID = _object.GetInstanceID();
			}
			
			if (!_isCurrentlyEdited)
			{
				if (GUILayout.Button("Edit","MiniButton",GUILayout.Width(40)))
				{
					StartEditingExistingProxy(details);
				}
			}else{
				GUI.color = Color.yellow;
				if (GUILayout.Button("Cancel","MiniButton",GUILayout.Width(40)))
				{
					StartEditingExistingProxy(details);
				}
				GUI.color = Color.white;
			}

			
			GUILayout.EndHorizontal();
		}