public static bool OnOpenAsset(int instanceID, int line) { var prefab = EditorUtility.InstanceIDToObject(instanceID) as GameObject; if (prefab != null && prefab.GetComponent <RectTransform>()) { GenCodeUtil.ChoiseAnUserMonobehiver(prefab, v => { if (v) { var window = GetWindow <BindingWindow>(); window.OpenWith(v); } }); return(true); } return(false); }
private void DrawObjectField() { using (var hor = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("预制体:", EditorStyles.toolbarButton, GUILayout.Width(lableWidth))) { ToggleOpen(); } EditorGUI.BeginChangeCheck(); prefab = EditorGUILayout.ObjectField(prefab, typeof(GameObject), false) as GameObject; if (EditorGUI.EndChangeCheck()) { GenCodeUtil.ChoiseAnUserMonobehiver(prefab, v => { OpenWith(v); }); } } }
private void DrawPreComponents() { using (var hor = new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("←", "快速解析"), EditorStyles.toolbarButton, GUILayout.Width(20))) { GenCodeUtil.ChoiseAnUserMonobehiver(prefab, component => { if (component == null) { EditorApplication.Beep(); } else { //从旧的脚本解析出 GenCodeUtil.AnalysisComponent(component, components, rule); } }); } } using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("BaseType:", GUILayout.Width(lableWidth)); rule.baseTypeIndex = EditorGUILayout.Popup(rule.baseTypeIndex, GenCodeUtil.supportBaseTypes); if (GUILayout.Button(new GUIContent("update", "更新脚本控件信息"), EditorStyles.miniButton, GUILayout.Width(60))) { var go = prefab; rule.bindingAble = BindingAble; GenCodeUtil.UpdateScripts(go, components, rule); } } preComponentList.DoLayoutList(); var addRect = GUILayoutUtility.GetRect(BridgeUI.Drawer.BridgeEditorUtility.currentViewWidth, EditorGUIUtility.singleLineHeight); if (addRect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.DragUpdated) { if (DragAndDrop.objectReferences.Length > 0) { foreach (var item in DragAndDrop.objectReferences) { if (item is GameObject || item is ScriptableObject) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; } } } } else if (Event.current.type == EventType.DragPerform) { if (DragAndDrop.objectReferences.Length > 0) { foreach (var item in DragAndDrop.objectReferences) { if (item is GameObject) { var obj = item as GameObject; var parent = PrefabUtility.GetPrefabParent(obj); if (parent) { obj = parent as GameObject; } var c_item = new ComponentItem(obj); c_item.components = GenCodeUtil.SortComponent(obj); components.Add(c_item); } else if (item is ScriptableObject) { var c_item = new ComponentItem(item as ScriptableObject); components.Add(c_item); } } DragAndDrop.AcceptDrag(); } } } }