public override void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayoutEx.Toggle("Append Clean Snapshot", ref appendCleanSnapshot); EditorGUILayout.EndVertical(); if (GUILayout.Button("Build", GUILayout.Height(50))) { path.Save(AssetBundlePath.PATH); Build(); } EditorGUILayout.EndHorizontal(); path.DrawInspectorGUI(); EditorGUIEx.DrawSeparator(); // if (GUILayout.Button("Find Duplicates")) // { // duplicates = AssetBundler.inst.FindDuplicateAssetBundles(); // } // if (duplicates != null) // { //ListDrawer<AssetBundleDup> drawer = new ListDrawer<AssetBundleDup>(duplicates, new AssetBundleDupDrawer()); // drawer.Draw(); //} }
static public float GetPropertyHeight(SerializedProperty property, GUIContent label) { //PropertyDrawer drawer = PropertyDrawer.GetDrawer(property); //if (drawer != null) //{ // return drawer.GetPropertyHeight(property.Copy(), label ?? EditorGUIUtility.TempContent(property.displayName)); //} property = property.Copy(); SerializedProperty endProperty = property.GetEndProperty(); float height = EditorGUIEx.GetSinglePropertyHeight(property, label); bool enterChildren = property.isExpanded && EditorGUIEx.HasVisibleChildFields(property); while (property.NextVisible(enterChildren) && !SerializedProperty.EqualContents(property, endProperty)) { //drawer = PropertyDrawer.GetDrawer(property); //if (drawer != null) //{ // height += drawer.GetPropertyHeight(property.Copy(), EditorGUIUtility.TempContent(property.displayName)); // enterChildren = false; //} //else { height += EditorGUIEx.GetSinglePropertyHeight(property); enterChildren = (property.isExpanded && EditorGUIEx.HasVisibleChildFields(property)); } } return(height); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Tooltip tooltipAttribute = attribute as Tooltip; label.tooltip = tooltipAttribute.text; EditorGUIEx.PropertyField(position, property, label); }
public void OnSpyglassGUI() { var controller = AssetDatabase.LoadAssetAtPath <AnimatorController>(AssetDatabase.GetAssetPath(target.runtimeAnimatorController)); if (controller == null) { return; } using (EditorGUILayoutEx.ScrollView(ref m_ScrollPosition)) { using (GUILayoutEx.Vertical()) { foreach (AnimatorControllerParameter parameter in controller.parameters) { switch (parameter.type) { case AnimatorControllerParameterType.Float: { float value = target.GetFloat(parameter.name); using (EditorGUIEx.ChangeCheck(() => target.SetFloat(parameter.name, value))) { value = EditorGUILayout.FloatField(parameter.name, value); } } break; case AnimatorControllerParameterType.Int: { int value = target.GetInteger(parameter.name); using (EditorGUIEx.ChangeCheck(() => target.SetInteger(parameter.name, value))) { value = EditorGUILayout.IntField(parameter.name, value); } } break; case AnimatorControllerParameterType.Bool: { bool value = target.GetBool(parameter.name); using (EditorGUIEx.ChangeCheck(() => target.SetBool(parameter.name, value))) { value = EditorGUILayout.Toggle(parameter.name, value); } } break; case AnimatorControllerParameterType.Trigger: if (GUILayout.Button(parameter.name)) { target.SetTrigger(parameter.name); } break; } } } } }
protected override void ValueGUIImpl() { if (isFlags) { TypedDrawingValue = EditorGUIEx.EnumFlagsField(TypedDrawingValue); } else { typedDrawnValue = EditorGUIEx.EnumPopup(TypedDrawingValue); } }
private void UpdateSettingsGUI() { var updateMode = Settings.DrawerUpdateMode; updateMode = EditorGUIEx.EnumPopup(dataUpdateModeContent, updateMode); switch (updateMode) { case DrawerUpdateMode.TimeInterval: Settings.DrawerUpdateTimeInterval = EditorGUILayout .FloatField(timeIntervalContent, Settings.DrawerUpdateTimeInterval); break; } Settings.DrawerUpdateMode = updateMode; }
private void OnGui(Rect position, ButtonDropWindow.Styles styles) { GUI.Label(new Rect(0.0f, 0.0f, position.width, position.height), GUIContent.none, styles.background); var rect = position; rect.x = +1f; rect.y = +0f; rect.width -= 2f; //rect.height -= 2f; using (GUILayoutEx.Area(rect)) { rect = GUILayoutUtility.GetRect(10f, 25f); GUI.Label(rect, "New Script", styles.header); GUILayout.Label("Name:"); m_ScriptName = EditorGUILayout.TextField(m_ScriptName); GUILayout.Label("Namespace:"); using (GUILayoutEx.Horizontal()) { m_Namespace = EditorGUILayout.TextField(m_Namespace); if (GUILayout.Button("S", GUILayout.Width(20))) { } } GUILayout.Label("Path:"); using (GUILayoutEx.Horizontal()) { m_Path = EditorGUILayout.TextField(m_Path); if (GUILayout.Button("S", GUILayout.Width(20))) { } } string scriptPath = Path.Combine(m_Path, m_ScriptName + ".cs"); using (EditorGUIEx.DisabledScopeIf(File.Exists(scriptPath))) { if (GUILayout.Button("Create and Add")) { CreateScript(scriptPath); ButtonDropWindow.Close(); } } } }
protected virtual void PageSelectGUI() { using (new EditorGUILayout.HorizontalScope()) { EditorGUIEx.MinWidthLabelField(GetItemCountText()); if (DIGUI.PageFlipButton(DIGUIContents.PrevButton)) { CurrentPageIndex--; } int pageCount = PageCount; int pageNo = pageCount == 0 ? 0 : CurrentPageIndex + 1; pageNo = EditorGUIEx.MinWidthDelayedIntField(pageNo); CurrentPageIndex = pageCount == 0 ? 0 : pageNo - 1; EditorGUIEx.MinWidthLabelField("/" + PageCount); if (DIGUI.PageFlipButton(DIGUIContents.NextButton) && ItemCountInCurrentPage == ItemCountPerPage) { CurrentPageIndex++; } } }
void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <TextAsset>(ref assetToCompress, false); GUI.enabled = assetToCompress != null; if (GUILayout.Button("Compress")) { string src = AssetDatabase.GetAssetPath(assetToCompress); string dst = StringUtil.InsertSuffix(src, "_compress"); dst = AssetDatabase.GenerateUniqueAssetPath(dst); byte[] compressed = CLZF.Compress(assetToCompress.bytes); FileStream os = new FileStream(dst, FileMode.CreateNew); os.Write(compressed, 0, compressed.Length); os.Close(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <TextAsset>(ref assetToDecompress, false); GUI.enabled = assetToDecompress != null; if (GUILayout.Button("Decompress")) { string src = AssetDatabase.GetAssetPath(assetToDecompress); string dst = StringUtil.InsertSuffix(src, "_decompress"); dst = AssetDatabase.GenerateUniqueAssetPath(dst); byte[] decompressed = CLZF.Decompress(assetToCompress.bytes); FileStream os = new FileStream(dst, FileMode.CreateNew); os.Write(decompressed, 0, decompressed.Length); os.Close(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; }
private void DrawFrames(List <FrameConfig> frames, List <object> actions, Rect rect) { int frameCnt = frames.Count; float headWidth = 20f; float topHeight = 30f; float frameWidth = win.setting.frameWidth; float frameSpace = 4f; float actionHeight = 30f; float actionSpace = 4f; float actionOffset = 0f; float barSize = 16f; float viewHeight = rect.height - barSize - topHeight; float viewWidth = frameWidth * frameCnt; float minViewWidth = rect.width - barSize - headWidth; if (viewWidth < minViewWidth) { viewWidth = minViewWidth; } float actionsHeight = actionHeight * actions.Count; if (actionsHeight > viewHeight) { viewHeight = actionsHeight + actionHeight; } Rect framePosition = new Rect(rect.x + headWidth, rect.y, rect.width - headWidth - barSize, rect.height - barSize); Rect frameView = new Rect(framePosition.x, framePosition.y, viewWidth, rect.height - barSize); Rect actionIdPosition = new Rect(rect.x, rect.y + topHeight, headWidth, rect.height - barSize - topHeight); Rect actionIdView = new Rect(actionIdPosition.x, actionIdPosition.y, headWidth, viewHeight); Rect actionPosition = new Rect(rect.x + headWidth, rect.y + topHeight, rect.width - headWidth, rect.height - topHeight); Rect actionView = new Rect(actionPosition.x, actionPosition.y, viewWidth, viewHeight); Rect beginFrameRt = new Rect(frameView.x, frameView.y, frameWidth, frameView.height); Rect beginActionIdRect = new Rect(actionIdView.x, actionIdView.y, headWidth, actionHeight); Rect beginActionRt = new Rect(actionView.x, actionView.y, actionView.width, actionHeight); Rect beginActionBgRt = new Rect(actionView.x, actionView.y, actionView.width, actionHeight); Rect beginFrameBtnRt = beginFrameRt; beginFrameBtnRt.height = topHeight; Rect beginFrameBgRt = beginFrameRt; beginFrameBgRt.y += topHeight; beginFrameBgRt.height = frameView.height - topHeight; //----------------------------------------------------- #region 帧 GUI.BeginScrollView(framePosition, Vector2.right * actionViewScroll.x, frameView, GUIStyle.none, GUIStyle.none); for (int i = 0; i < frameCnt; i++) { Rect btnRt = beginFrameBtnRt; btnRt.x += frameWidth * i; btnRt.width -= frameSpace; Rect bgRt = beginFrameBgRt; bgRt.x += frameWidth * i; bgRt.width -= frameSpace; bool selected = win.frameSelectIndex == i; FrameConfig config = win.currentFrames[i]; string title = string.Format("{0}\n{1}|{2}", i, config.stayAttackRange ? "←" : (config.attackRanges?.Count ?? 0).ToString(), config.stayBodyRange ? "←" : (config.bodyRanges?.Count ?? 0).ToString()); if (GUI.Button(btnRt, title, selected ? AEStyles.item_head_select : AEStyles.item_head_normal)) { win.frameSelectIndex = selected ? -1 : i; } GUI.Box(bgRt, GUIContent.none, selected ? AEStyles.item_body_select : AEStyles.item_body_normal); } GUI.EndScrollView(); #endregion 帧 //----------------------------------------------------- #region 控制条 actionViewScroll = GUI.BeginScrollView(actionPosition, actionViewScroll, actionView, true, true); for (int i = 0; i < actions.Count; i++) { object action = actions[i]; int beginFrame = 0; int endFrame = frameCnt - 1; IHoldFrames holdFrames = action as IHoldFrames; if (holdFrames != null) { beginFrame = holdFrames.GetBeginFrame(); endFrame = holdFrames.GetEndFrame(); } //minmaxslider Rect rt = beginActionRt; rt.y += actionHeight * i + actionOffset; rt.height -= (actionSpace + actionOffset); bool selected = win.actionSelectIndex == i; float beginValue = beginFrame * frameWidth; float endValue = (endFrame + 1) * frameWidth - 2 * EditorGUIEx.minMaxThumbWidth - frameSpace; bool clicked = EditorGUIEx.MinMaxSlider(rt, ref beginValue, ref endValue, 0, viewWidth - 2 * EditorGUIEx.minMaxThumbWidth); if (clicked) { win.actionSelectIndex = selected ? -1 : i; } if (holdFrames != null) { if (holdFrames.EnableBeginEnd()) { //校验 beginFrame = Mathf.RoundToInt(beginValue / frameWidth); endFrame = Mathf.RoundToInt((endValue + 2 * EditorGUIEx.minMaxThumbWidth + frameSpace) / frameWidth - 1); beginFrame = Mathf.Clamp(beginFrame, 0, frameCnt - 1); endFrame = Mathf.Clamp(endFrame, 0, frameCnt - 1); if (endFrame < beginFrame) { endFrame = beginFrame; } // } else {//设置最大值 beginFrame = 0; endFrame = frameCnt - 1; } holdFrames.SetBeginFrame(beginFrame); holdFrames.SetEndFrame(endFrame); } } GUI.EndScrollView(); #endregion 控制条 //----------------------------------------------------- #region 动作序号 GUI.BeginScrollView(actionIdPosition, Vector2.up * actionViewScroll.y, actionIdView, GUIStyle.none, GUIStyle.none); for (int i = 0; i < actions.Count; i++) { Rect rt = beginActionIdRect; rt.y += actionHeight * i; rt.height -= actionSpace; bool selected = win.actionSelectIndex == i; if (GUI.Button(rt, $"{i}", selected ? AEStyles.item_head_select : AEStyles.item_head_normal)) { win.actionSelectIndex = selected ? -1 : i; } } GUI.EndScrollView(); #endregion 动作序号 //------------------------------------------- #region 动作信息 GUI.BeginScrollView(actionPosition, actionViewScroll, actionView, true, true); for (int i = 0; i < actions.Count; i++) { object action = actions[i]; //label Rect labelRt = beginActionBgRt; labelRt.y += actionHeight * i; labelRt.height -= actionSpace; labelRt.width = viewWidth; bool selected = win.actionSelectIndex == i; if (GUI.Button(labelRt, $"{action.ToString()}", AEStyles.frame_label)) { win.actionSelectIndex = selected ? -1 : i; } } GUI.EndScrollView(); #endregion 动作信息 }
public override void OnInspectorGUI() { if (nestedPrefab.GetPrefab() != null) { EditorGUILayout.ObjectField(nestedPrefab.GetPrefab(), typeof(GameObject), false); } if (AssetDatabase.IsMainAsset(nestedPrefab.gameObject) || AssetDatabase.IsSubAsset(nestedPrefab.gameObject)) { return; } if (nestedPrefab.IsLinked()) { if (GUILayout.Button("Unlink Prefabs")) { PrefabRestore restore = new PrefabRestore(); nestedPrefab.transform.DepthFirstTraversal(restore.Apply); restore.Destroy(); } } else { if (GUILayout.Button("Link Prefabs")) { Build(); } } GameObject rootPrefab = PrefabUtility.GetPrefabParent(nestedPrefab.gameObject) as GameObject; EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <Object>("Folder", ref folder, false); GUI.enabled = folder != null; if (GUILayout.Button("Create Prefab")) { if (!nestedPrefab.IsLinked()) { Build(); } string dir = EditorAssetUtil.GetAssetFileFullPath(AssetDatabase.GetAssetPath(folder)); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); AssetDatabase.Refresh(ImportAssetOptions.Default); } string path = AssetDatabase.GenerateUniqueAssetPath(PathUtil.Combine(AssetDatabase.GetAssetPath(folder), nestedPrefab.name + ".prefab")); rootPrefab = PrefabUtility.CreatePrefab(path, nestedPrefab.gameObject); Selection.activeGameObject = rootPrefab; } EditorGUILayout.EndHorizontal(); GUI.enabled = true; if (rootPrefab != null) { if (GUILayout.Button("Disconnect Prefab")) { PrefabUtility.DisconnectPrefabInstance(nestedPrefab.gameObject); } } if (EditorGUIEx.Toggle("Instantiate On Start", ref nestedPrefab.instantiateOnStart)) { EditorUtil.SetDirty(nestedPrefab); } if (EditorGUIEx.Toggle("Destroy On Instantiation", ref nestedPrefab.destroyOnInstantiation)) { EditorUtil.SetDirty(nestedPrefab); } }
protected override void ValueGUIImpl() { typedDrawnValue = EditorGUIEx.ObjectField(TypedDrawingValue, true); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { return(EditorGUIEx.GetPropertyHeight(property, label)); }