public static List <EditorWindow> GetAllInspector() { var type = XReflectionUtils.GetUnityEditor("UnityEditor.InspectorWindow"); var returnValue = type.TryInvokeGlobalMethod("GetInspectors"); return((List <EditorWindow>)returnValue); }
public void OpenInMethodExten() { Type windowType = XReflectionUtils.TryGetClass("XMethodWindow"); object window = windowType.TryInvokeGlobalMethod("Init"); windowType.TrySetProperty(window, "Target", this); }
public static EditorWindow GetInspectorWindow() { var type = XReflectionUtils.GetUnityEditor("UnityEditor.InspectorWindow"); var window = EditorWindow.GetWindow(type); return(window); }
void MatchPara() { var functions = command.RegexCutString("(", ")"); var clear = command.RegexCutStringReverse("(", ")"); string[] commandPara = clear.Split('.'); if (commandPara.Length > 0 && type == null && currValue == null) { type = XReflectionUtils.TryGetClass(commandPara[0]); } currValue = draggedObject; int allLenght = commandPara.Length; int funCount = functions.Length; int startIndex = 1; if (currValue != null) { startIndex = 0; } for (int i = startIndex; i < startIndex + funCount; i++) { // TODO loop in funCount if (currValue == null) { currValue = type.TryInvokeGlobalMethod(commandPara[i]); } else { currValue = currValue.GetType().TryInvokeMethod(currValue, commandPara[i]); } } int fieldCount = commandPara.Length - funCount; int fieldIndex = 1; if (currValue != null) { fieldIndex = 0; } for (int pos = fieldIndex; pos < fieldCount; pos++) { // TODO loop in Length if (currValue == null) { currValue = type.TrySearchGlobalMemberValue(commandPara[pos + startIndex]); } else { currValue = currValue.TryGetFieldValue(commandPara[pos + startIndex]); } } Debug.Log("currValue is : " + currValue.ToString()); }
void HandleInput(Event e) { if (Event.current.isKey) { Listen(); string[] paras = command.Split('.'); switch (paras.Length) { case 1: isClassIntent = false; isMethodIntent = false; isFieldIntent = false; searchCollection = TryGetClass(paras[0]); break; case 2: if (!isClassIntent) { type = XReflectionUtils.TryGetClass(paras[0]); isClassIntent = true; isMethodIntent = false; isFieldIntent = false; } searchCollection = TryGetMember(paras[1], true); break; case 3: if (!isMethodIntent) { // object instance = TryInvokeGlobalFunction( paras[1] ); // type = instance.GetType(); // isMethodIntent = true; } searchCollection = TryGetMember(paras[2], false); break; default: break; } } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (var draggedObject in DragAndDrop.objectReferences) { this.draggedObject = draggedObject; } } Repaint(); }
static void DidReloadScripts() { hierchyTypes = XReflectionUtils.FindAllSubClass(typeof(HierchyAbstract)).ToArray(); hierchyObjects = new object[hierchyTypes.Length]; // XLogger.Log("Didreload script quick toogle {0}".StringFormat(hierchyTypes.Length)); for (int i = 0; i < hierchyTypes.Length; i++) { hierchyObjects[i] = Activator.CreateInstance(hierchyTypes[i]); // XLogger.Log("hierchyObjects {0}".StringFormat(hierchyObjects[i].ToString())); } }
void SelecteFsmObject() { if (currState == null) { Selection.objects = new UnityEngine.Object[] { fsm } } ; } void CreateStateMenu(Vector2 position) { GenericMenu gm = new GenericMenu(); if (currState == null) { List <Type> subClasses = new List <Type>(); subClasses.AddRange(XReflectionUtils.FindSubClass(typeof(FsmState)).ToList()); foreach (var item in subClasses) { gm.AddItem(new GUIContent(item.Name), false, (t) => { var state = item.Assembly.CreateInstance((t as Type).FullName, false); var fsmState = state as FsmState; fsmState.owner = fsm; fsmState.name = (t as Type).Name; fsmState.position = position; fsm.AddState(fsmState); }, item); } } else { gm.AddItem(new GUIContent("Set Default"), false, () => { fsm.SetDefaultState(currState); }); gm.AddItem(new GUIContent("Remove"), false, () => { fsm.RemoveState(currState); SelecteFsmObject(); }); } gm.ShowAsContext(); } }
void MeshSetup() { var meshFilter = gameObject.GetComponent <MeshFilter>(); if (meshFilter.sharedMesh != null) { DestroyImmediate(meshFilter.sharedMesh, true); } mesh = new Mesh(); mesh.name = name; meshFilter.sharedMesh = mesh; mesh.vertices = Vertices.ToArray(); mesh.triangles = Triangles.ToArray(); mesh.uv = UV.ToArray(); var type = XReflectionUtils.GetPrefabType(gameObject); if (type == "Prefab") { XReflectionUtils.AddObjectToObject(mesh, gameObject); } }
public override void OnClickNode(DragNode targetNode) { currNode = ( BTNode )targetNode; var allActions = XReflectionUtils.FindSubClass(typeof(BTAction)).ToList(); var allVariables = XReflectionUtils.FindSubClass(typeof(BTVariable)).ToList(); GenericMenu gm = new GenericMenu(); gm.AddItem(new GUIContent("New Fsm Event"), false, ClickNode, ( object )"NewEvent"); gm.AddItem(new GUIContent("Open State Script"), false, ClickNode, "OpenScript"); gm.AddItem(new GUIContent("Delet State"), false, ClickNode, ( object )"DeleteState"); gm.AddItem(new GUIContent("Copy State"), false, ClickNode, "CopyState"); for (int i = 0; i < allActions.Count; i++) { var allObject = allActions[i].GetCustomAttributes(typeof(ActionTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Action/" + (( ActionTitleAttribute )allObject[0]).title), false, ClickNode, ( object )allActions[i].AssemblyQualifiedName); } } gm.ShowAsContext(); }
public override void OnClickNone(BTFsm targetNode) { currFsm = targetNode; GenericMenu gm = new GenericMenu(); gm.AddItem(new GUIContent("New Fsm Event"), false, ClickNone, "NewGlobalEvent"); gm.AddItem(new GUIContent("New Fsm State"), false, ClickNone, "NewState"); gm.AddItem(new GUIContent("Cancel Edit Fsm"), false, ClickNone, "CancelEditFsm"); if (copyState != null) { gm.AddItem(new GUIContent("Paste State"), false, ClickNone, "PasteState"); } var allState = XReflectionUtils.FindUnitySubClass(typeof(BTState)).ToList(); for (int i = 0; i < allState.Count; i++) { var allObject = allState[i].GetCustomAttributes(typeof(StateTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Custom State/" + (( StateTitleAttribute )allObject[0]).title), false, AddCustomState, ( object )allState[i].AssemblyQualifiedName); } } var allVariables = XReflectionUtils.FindUnitySubClass(typeof(BTVariable)).ToList(); for (int i = 0; i < allVariables.Count; i++) { var allObject = allVariables[i].GetCustomAttributes(typeof(ActionTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Variable/" + (( ActionTitleAttribute )allObject[0]).title), false, ClickNone, ( object )allVariables[i].AssemblyQualifiedName); } } gm.ShowAsContext(); }
public void SetDirty() { XReflectionUtils.SetDirty(this); }
public override void OnInitialization(params object[] args) { webViewType = XReflectionUtils.TryGetClass("WebView"); //Init web view InitWebView(); }
public static System.Type GetClass(string className) { return(XReflectionUtils.TryGetClass(className)); }
void InitMesh() { //-----------------Head-----------------// var mesh = new Mesh(); mesh1.sharedMesh = mesh; List <Vector3> Vertices = new List <Vector3> (); List <Vector2> UV = new List <Vector2> (); List <int> Triangles = new List <int> (); List <Color> Colors = new List <Color> (); Vector3 lastLT = Vector3.zero; Vector3 lastLD = Vector3.zero; Vector3 leftTop; Vector3 leftDown; Vector3 rightDown; Vector3 rightTop; float y = step * yWidthCurve.Evaluate(0.02f) / 2; float y2 = step * yWidthCurve.Evaluate(0.01f) / 2; var p = GetBezierCurve(position0, position1, position2, position3, -headWid); var np = GetBezierCurve(position0, position1, position2, position3, 0f); rightTop = new Vector3(step, step * y2 * 0.5f) + np; rightDown = new Vector3(step, -y2 * 0.5f) + np; leftTop = new Vector3(-step, step * y * 0.5f) + p; leftDown = new Vector3(-step, -y * 0.5f) + p; Vertices.Add(leftTop); Vertices.Add(leftDown); Vertices.Add(rightTop); Vertices.Add(rightDown); UV.Add(new Vector2(0, 1)); UV.Add(new Vector2(0, 0)); UV.Add(new Vector2(1, 1)); UV.Add(new Vector2(1, 0)); Triangles.AddRange(new List <int> { 0, 2, 3 }); Triangles.AddRange(new List <int> { 0, 3, 1 }); mesh.vertices = Vertices.ToArray(); mesh.uv = UV.ToArray(); mesh.triangles = Triangles.ToArray(); mesh.name = mesh1.name; var type = XReflectionUtils.GetPrefabType(gameObject); if (type == "Prefab") { XReflectionUtils.AddObjectToObject(mesh, mesh1.gameObject); } //-----------------Trail-----------------// Vertices.Clear(); UV.Clear(); Triangles.Clear(); Colors.Clear(); mesh = new Mesh(); mesh2.sharedMesh = mesh; int currIndex = 0; float UVDelta = 1.0f / UVCount; for (int i = 0; i < stepCount; i++) { float t = i * 1.0f / stepCount; float nextT = (i + 1) * 1.0f / stepCount; int uvIndex = i; float leftUV = uvIndex * UVDelta; float rightUV = (uvIndex + 1) * UVDelta; Color leftColor = gradient.Evaluate(t); Color rightColor = gradient.Evaluate(nextT); p = GetBezierCurve(position0, position1, position2, position3, t); y = step * yWidthCurve.Evaluate(t) / 2; if (lastLT != Vector3.zero) { leftTop = lastLT; } else { leftTop = new Vector3(step, step * y * 0.5f) + p; Vertices.Add(leftTop); UV.Add(new Vector2(leftUV, 1)); Colors.Add(leftColor); } if (lastLD != Vector3.zero) { leftDown = lastLD; } else { leftDown = new Vector3(step, -y * 0.5f) + p; Vertices.Add(leftDown); UV.Add(new Vector2(leftUV, 0)); Colors.Add(leftColor); } if (i == 0) { rightTop = new Vector3(step, step * y * 0.5f) + p; rightDown = new Vector3(step, -y * 0.5f) + p; } else { rightTop = new Vector3(step, step * y * 0.5f) + p; rightDown = new Vector3(step, -y * 0.5f) + p; } Vertices.Add(rightTop); UV.Add(new Vector2(rightUV, 1)); Colors.Add(rightColor); Vertices.Add(rightDown); UV.Add(new Vector2(rightUV, 0)); Colors.Add(rightColor); lastLT = new Vector3(rightTop.x, rightTop.y * 0.5f, rightTop.z); lastLD = new Vector3(rightDown.x, rightDown.y * 0.5f, rightDown.z); currIndex = i * 2; Triangles.AddRange(new List <int> { currIndex, currIndex + 2, currIndex + 3 }); Triangles.AddRange(new List <int> { currIndex, currIndex + 3, currIndex + 1 }); } mesh.vertices = Vertices.ToArray(); mesh.uv = UV.ToArray(); mesh.triangles = Triangles.ToArray(); mesh.name = mesh2.name; mesh.colors = Colors.ToArray(); type = XReflectionUtils.GetPrefabType(gameObject); if (type == "Prefab") { XReflectionUtils.AddObjectToObject(mesh, mesh2.gameObject); } }