public override void OnGUI(Rect position) { base.OnGUI(position); this.BeginArea(position) .Label("BuildSetting") .Label("", GUIStyles.Get("IN Title"), GUILayout.Height(5)) .Label("Build Target:") .Label(EditorUserBuildSettings.activeBuildTarget.ToString()) .Label("", GUIStyles.Get("IN Title"), GUILayout.Height(5)) .Label("AssetBundle OutPath:") .Label("Assets/../AssetBundles") .Label("", GUIStyles.Get("IN Title"), GUILayout.Height(5)) .Label("Manifest FilePath:") .Label(ABTool.ManifestPath) .Label("", GUIStyles.Get("IN Title"), GUILayout.Height(5)) .Space(10) .Label("LoadSetting In Editor") .Pan(() => { ABTool.ActiveBundleMode = !EditorGUILayout.Toggle(new GUIContent("AssetDataBase Load"), !ABTool.ActiveBundleMode); }) .Space(10) .Button(() => { ABBuild.DeleteBundleFile(); }, "Clear Bundle Files") .Button(() => { ABBuild.BuildManifest(ABTool.ManifestPath, ABBuiidInfo.GetAssetBundleBuilds()); }, "Build Manifest") .Button(() => { ABBuild.BuildManifest(ABTool.ManifestPath, ABBuiidInfo.GetAssetBundleBuilds()); ABBuild.BuildAssetBundles(ABBuiidInfo.GetAssetBundleBuilds(), EditorUserBuildSettings.activeBuildTarget); ProcessUtil.OpenFloder(ABTool.AssetBundlesOutputDirName); }, "Build AssetBundle") .Button(() => { ABBuild.CopyAssetBundlesTo(Application.streamingAssetsPath); }, "copy to Stream") .EndArea(); }
private void ABBContentWinGUI(Rect rect) { rect.DrawOutLine(2, Color.black); int lineCount = ChossedABB == null ? 0 : ChossedABB.assetNames.Count; ABBContentTable.Calc(rect, new Vector2(rect.x, rect.y + LineHeight), ABBContentScrollPos, LineHeight, lineCount, ABBContentSetting); this.Label(ABBContentTable.titleRow.position, "", TitleStyle) .Label(ABBContentTable.titleRow[AssetName].position, AssetName) .Label(ABBContentTable.titleRow[Bundle].position, Bundle) .Label(ABBContentTable.titleRow[Size].position, Size); Event e = Event.current; this.DrawScrollView(() => { for (int i = ABBContentTable.firstVisibleRow; i < ABBContentTable.lastVisibleRow + 1; i++) { ABDeprndence asset = GetDpByName(ChossedABB.assetNames[i]); GUIStyle style = i % 2 == 0 ? EntryBackEven : EntryBackodd; if (e.type == EventType.Repaint) { style.Draw(ABBContentTable.rows[i].position, false, false, ABBContentTable.rows[i].selected, false); } this.Label(ABBContentTable.rows[i][Size].position, asset.Size) .Label(ABBContentTable.rows[i][AssetName].position, asset.AssetName) .Label(ABBContentTable.rows[i][Preview].position, asset.ThumbNail) .Label(ABBContentTable.rows[i][Bundle].position, asset.BundleName) .Pan(() => { if (asset.AssetBundles.Count == 1) { this.Label(ABBContentTable.rows[i][CrossRef].position, EditorGUIUtility.IconContent("Collab")); } else { this.Label(ABBContentTable.rows[i][CrossRef].position, asset.AssetBundles.Count.ToString(), GUIStyles.Get("CN CountBadge")); } }); if (e.modifiers == EventModifiers.Control && e.button == 0 && e.clickCount == 1 && ABBContentTable.rows[i].position.Contains(Event.current.mousePosition)) { ABBContentTable.ControlSelectRow(i); window.Repaint(); } else if (e.modifiers == EventModifiers.Shift && e.button == 0 && e.clickCount == 1 && ABBContentTable.rows[i].position.Contains(e.mousePosition)) { ABBContentTable.ShiftSelectRow(i); window.Repaint(); } else if (e.button == 0 && e.clickCount == 1 && ABBContentTable.rows[i].position.Contains(e.mousePosition)) { ABBContentTable.SelectRow(i); ChoosedAsset = asset; window.Repaint(); } } }, ABBContentTable.view, ref ABBContentScrollPos, ABBContentTable.content, false, false); Handles.color = Color.black; for (int i = 0; i < ABBContentTable.titleRow.columns.Count; i++) { var item = ABBContentTable.titleRow.columns[i]; if (i != 0) { Handles.DrawAAPolyLine(1, new Vector3(item.position.x - 2, item.position.y, 0), new Vector3(item.position.x - 2, item.position.yMax - 2, 0)); } } ABBContentTable.position.DrawOutLine(2, Color.black); Handles.color = Color.white; if (e.button == 0 && e.clickCount == 1 && (ABBContentTable.view.Contains(e.mousePosition) && !ABBContentTable.content.Contains(e.mousePosition))) { ABBContentTable.SelectNone(); ChoosedAsset = null; window.Repaint(); } if (e.button == 1 && e.clickCount == 1 && ABBContentTable.content.Contains(e.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, () => { ABBContentTable.selectedRows.ReverseForEach((row) => { window.RemoveAsset(ChossedABB.assetNames[row.rowID], ChossedABB.assetBundleName); }); window.UpdateInfo(); ChoosedAsset = null; }); menu.ShowAsContext(); if (e.type != EventType.Layout) { e.Use(); } } }
private void ListView(Event e) { tableViewCalc.Calc(position, new Vector2(position.x, position.y + lineHeight), ScrollPos, lineHeight, DirCollect.DirCollectItems.Count, Setting); if (Event.current.type == EventType.Repaint) { GUIStyles.Get(EntryBackodd).Draw(tableViewCalc.position, false, false, false, false); } bool tog = true; this.Toggle(tableViewCalc.titleRow.position, ref tog, GUIStyles.Get(TitleStyle)) .LabelField(tableViewCalc.titleRow[CollectType].position, CollectType) .LabelField(tableViewCalc.titleRow[BundleName].position, BundleName) .LabelField(tableViewCalc.titleRow[SearchPath].position, SearchPath); this.DrawScrollView(() => { for (int i = tableViewCalc.firstVisibleRow; i < tableViewCalc.lastVisibleRow + 1; i++) { GUIStyle style = i % 2 == 0 ? EntryBackEven : EntryBackodd; if (e.type == EventType.Repaint) { style.Draw(tableViewCalc.rows[i].position, false, false, tableViewCalc.rows[i].selected, false); } if (e.modifiers == EventModifiers.Control && e.button == 0 && e.clickCount == 1 && tableViewCalc.rows[i].position.Contains(e.mousePosition)) { tableViewCalc.ControlSelectRow(i); window.Repaint(); } else if (e.modifiers == EventModifiers.Shift && e.button == 0 && e.clickCount == 1 && tableViewCalc.rows[i].position.Contains(e.mousePosition)) { tableViewCalc.ShiftSelectRow(i); window.Repaint(); } else if (e.button == 0 && e.clickCount == 1 && tableViewCalc.rows[i].position.Contains(e.mousePosition)) { tableViewCalc.SelectRow(i); window.Repaint(); } ABDirCollectItem item = DirCollect.DirCollectItems[i]; int index = (int)item.CollectType; this.Popup(tableViewCalc.rows[i][CollectType].position, ref index, Enum.GetNames(typeof(ABDirCollectItem.ABDirCollectType))); item.CollectType = (ABDirCollectItem.ABDirCollectType)index; this.Button(() => { chosseWindow.assetinfo = item.subAsset; PopupWindow.Show(tableViewCalc.rows[i][SelectButton].position, chosseWindow); } , tableViewCalc.rows[i][SelectButton].position, SelectButton); this.Label(tableViewCalc.rows[i][SearchPath].position, item.SearchPath); if (item.CollectType == ABDirCollectItem.ABDirCollectType.ABName) { this.TextField(tableViewCalc.rows[i][BundleName].position, ref item.BundleName); } } }, tableViewCalc.view, ref ScrollPos, tableViewCalc.content, false, false); Handles.color = Color.black; for (int i = 0; i < tableViewCalc.titleRow.columns.Count; i++) { var item = tableViewCalc.titleRow.columns[i]; if (i != 0) { Handles.DrawAAPolyLine(1, new Vector3(item.position.x - 2, item.position.y, 0), new Vector3(item.position.x - 2, item.position.yMax - 2, 0)); } } tableViewCalc.position.DrawOutLine(2, Color.black); Handles.color = Color.white; }
public GUISetup() { GUIStyle style = null; var border1 = new RectOffset(1, 1, 1, 1); var border2 = new RectOffset(2, 2, 2, 2); var texSize1 = new Rect(1, 1, 1, 1); var texSize2 = new Rect(2, 2, 1, 1); font = font != null ? font : Fonts.Get("Consolas", GUI.skin.font.fontSize); if (background == null) { background = GUIStyles.Get(GUI.skin.box, Vector2.zero, border2, 8, new Color(1f, 1f, 1f)); background.normal.background = Textures.Make(texSize2, new Color(0.3f, 0.3f, 0.3f), Color.black); } if (itemBG == null) { itemBG = new List <GUIStyle>(); float color = 0.8f; for (int i = 0; i < 5; i++) { style = GUIStyles.Get(String.Format("item_{0}_", i), GUI.skin.box, Vector2.zero, border1, 8, new Color(1f, 1f, 1f)); style.normal.background = Textures.Make(texSize1, new Color(color, color, color), Color.black); itemBG.Add(style); color -= 0.05f; } } if (titleText == null) { titleText = GUIStyles.Get("text", GUI.skin.label, Vector2.zero, border1, 18, Color.black); titleText.fontStyle = FontStyle.Bold; titleText.alignment = TextAnchor.MiddleCenter; titleText.padding = new RectOffset(); } if (itemText == null) { itemText = GUIStyles.Get("text", GUI.skin.label, Vector2.zero, border1, 10, Color.black); itemText.alignment = TextAnchor.MiddleLeft; itemText.padding = new RectOffset(); } if (actives == null) { actives = new GUIStyle[2]; actives[0] = GUIStyles.Get("active_off_", GUI.skin.box, Vector2.zero, border1, 8, new Color(1f, 1f, 1f)); actives[0].normal.background = Textures.Make(texSize1, new Color(0.1f, 0.3f, 0.1f), Color.grey); actives[1] = GUIStyles.Get("active_on__", GUI.skin.box, Vector2.zero, border1, 8, new Color(1f, 1f, 1f)); actives[1].normal.background = Textures.Make(texSize1, new Color(0.1f, 1.0f, 0.1f), Color.black); } //d.Init(new Color(194f / 255f, 0, 0).rrrn(1), 512, 512, new Rect(vec2(-10), vec2(20)), "test"); //d.Clear(); ////d.Add(new Textures.Drawer.Sphere(5) { color = Color.red, elongate = vec3(2, 0, 2) }); ////d.Add(new Textures.Drawer.Sphere(5) { color = Color.black, fallout = 2.5f, skin = 0.1f, elongate = vec3(2, 0, 2) }); //d.Add(new Textures.Drawer.Box(vec3(6, 2, 2)) { color = Color.red }); //d.Add(new Textures.Drawer.SmoothSubstraction(new Textures.Drawer.Box(vec3(6, 2, 2)), // new Textures.Drawer.Box(vec3(2, 4, 6)), // 1) //{ color = Color.cyan }); ////d.Add(new Textures.Drawer.Torus(vec2(8, 1)) { color = Color.green, fallout = 1 }); ////d.Add(new Textures.Drawer.Hexagon(vec2(3, 1)) { color = Color.magenta, fallout = 1 }); ////d.Add(new Textures.Drawer.Triangle(vec3(0), vec3(2, 0, 0), vec3(1, 0, 2)) { color = Color.cyan, fallout = 1, rounding = 1 }); //d.Make(); //var txt = EditorGUILayout.GetControlRect(GUILayout.Width(d.texture.width), GUILayout.Height(d.texture.height)); //GUI.Box(txt, d.texture); }
public override void OnGUI(Rect position) { base.OnGUI(position); GUI.BeginGroup(position); Rect pos = new Rect(new Vector2(50, 10), new Vector2(400, 400)); GUI.Box(pos, ""); Handles.color = window._backgroundColor; Vector2 end = new Vector2(pos.width, pos.height) + pos.position; Handles.DrawLine(new Vector2(0, pos.height) + pos.position, end); end = new Vector2(0, pos.height) + pos.position; Handles.DrawLine(new Vector2(0, 0) + pos.position, end); float hCount = pos.width / cellsize; float vCount = pos.height / cellsize; hCount = Math.Min(hCount, vCount); Handles.DrawLine(pos.BottomLeft(), new Vector2(hCount * cellsize, pos.height - hCount * cellsize) + pos.position); int _index = 0; while (pos.height >= _index * cellsize) { float y = pos.height - _index * cellsize; Vector2 left = new Vector2(0, y) + pos.position; Vector2 right = new Vector2(pos.width, y) + pos.position; Handles.DrawLine(left, right); GUI.Label(new Rect(left + new Vector2(-20, -6), Vector2.one * 80), (_index * delta).ToString("0.0")); _index++; } _index = 0; while (pos.width >= _index * cellsize) { float x = _index * cellsize; Vector2 top = new Vector2(x, 0) + pos.position; Vector2 buttom = new Vector2(x, pos.height) + pos.position; Handles.DrawLine(top, buttom); GUI.Label(new Rect(buttom + new Vector2(-8, 0), Vector2.one * 80), (_index * delta).ToString("0.0")); _index++; } float per = 0; float _p = 0.002f; float pixels = cellsize * 1 / delta; while (per < 1) { var p1 = _converter.Convert(per / 1, per, 1); per += _p; var p2 = _converter.Convert(per / 1, per, 1); Handles.color = Color.Lerp(window._curveHeadColor, window._curveTrailColor, per); Handles.DrawLine(new Vector2((per - _p) * pixels, pos.height - p1 * pixels) + pos.position, new Vector2(per * pixels, pos.height - p2 * pixels) + pos.position); } var rect = new Rect(pos.BottomLeft() + new Vector2(0, 30), new Vector2(pos.width, 20)); var rs = rect.VerticalSplit(pos.width / 4 * 3, 20); _percent = EditorGUI.Slider(rs[0], "Percent", _percent, 0, 1); if (GUI.Button(rs[1], "Watch Curve")) { _percent = 0; if (tween != null) { tween.Complete(false); tween = null; } tween = TweenEx.DoGoto(0, 1, 5f, () => { return(_percent); }, (value) => { _percent = value; window.Repaint(); }, false, EditorEnv.envType) .SetEase(_ease) .OnCompelete(() => { _percent = 1; }) .SetDeltaTime((float)EditorEnv.env.deltaTime.TotalMilliseconds); } { var point = _converter.Convert(_percent, _percent, 1); Rect cone = new Rect(Vector2.zero, Vector2.one * 10); cone.center = new Vector2(_percent * pixels, pos.height - point * pixels) + pos.position; GUI.Box(cone, new GUIContent("", point.ToString()), GUIStyles.Get("U2D.createRect")); var content = new GUIContent(point.ToString()); var size = GUIStyles.Get("label").CalcSize(content); GUI.Label(new Rect(cone.position + Vector2.one * 10, size), content); } GUI.EndGroup(); }
private void Right(Rect position) { GUI.BeginGroup(position); Rect pos = new Rect(new Vector2(50, 10), new Vector2(300, 600)); GUI.Box(pos, ""); Handles.color = window._backgroundColor; Vector2 end = new Vector2(pos.width, pos.height) + pos.position; Handles.DrawLine(new Vector2(0, pos.height) + pos.position, end); end = new Vector2(0, pos.height) + pos.position; Handles.DrawLine(new Vector2(0, 0) + pos.position, end); float hCount = pos.width / cellsize; float vCount = pos.height / cellsize; hCount = Math.Min(hCount, vCount); Handles.DrawLine(pos.BottomLeft(), new Vector2(hCount * cellsize, pos.height - hCount * cellsize) + pos.position); int _index = 0; while (pos.height >= _index * cellsize) { float y = pos.height - _index * cellsize; Vector2 left = new Vector2(0, y) + pos.position; Vector2 right = new Vector2(pos.width, y) + pos.position; Handles.DrawLine(left, right); GUI.Label(new Rect(left + new Vector2(-20, -6), Vector2.one * 80), (_index * delta).ToString("0.0")); _index++; } _index = 0; while (pos.width >= _index * cellsize) { float x = _index * cellsize; Vector2 top = new Vector2(x, 0) + pos.position; Vector2 buttom = new Vector2(x, pos.height) + pos.position; Handles.DrawLine(top, buttom); GUI.Label(new Rect(buttom + new Vector2(-8, 0), Vector2.one * 80), (_index * delta).ToString("0.0")); _index++; } if (_curve != null) { float count = 1 / delta; float pixels = cellsize * count; float per = _curve.step; while (per < 1) { Handles.color = Color.Lerp(window._curveHeadColor, window._curveTrailColor, per); var p = _curve.GetPercent(per); per += _curve.step; var p2 = _curve.GetPercent(per); if (_type.HasFlag(LineType.X_Y)) { Handles.DrawLine(new Vector2(p.x * pixels, pos.height - p.y * pixels) + pos.position, new Vector2(p2.x * pixels, pos.height - p2.y * pixels) + pos.position); } if (_type.HasFlag(LineType.Percent_Y)) { Handles.DrawLine(new Vector2((per - _curve.step) * pixels, pos.height - (p.y) * pixels) + pos.position, new Vector2(per * pixels, pos.height - (p2.y) * pixels) + pos.position); } if (_type.HasFlag(LineType.Y_Speed)) { float _a = (p2 - p).y / _curve.step; Handles.DrawLine(new Vector2((per - _curve.step) * pixels, pos.height - _a * pixels) + pos.position, new Vector2(per * pixels, pos.height - _a * pixels) + pos.position); } } { if (_type.HasFlag(LineType.X_Y)) { var point = _curve.GetPercent(_percent); Rect cone = new Rect(Vector2.zero, Vector2.one * 10); cone.center = new Vector2(point.x * pixels, pos.height - point.y * pixels) + pos.position; GUI.Box(cone, new GUIContent("", point.ToString()), GUIStyles.Get("U2D.createRect")); var content = new GUIContent(point.ToString()); var size = GUIStyles.Get("label").CalcSize(content); GUI.Label(new Rect(cone.position + Vector2.one * 10, size), content); } } { if (_type.HasFlag(LineType.Percent_Y)) { var point = _curve.GetPercent(_percent); Rect cone = new Rect(Vector2.zero, Vector2.one * 10); cone.center = new Vector2(_percent * pixels, pos.height - point.y * pixels) + pos.position; GUI.Box(cone, new GUIContent("", point.ToString()), GUIStyles.Get("U2D.createRect")); var content = new GUIContent(point.ToString()); var size = GUIStyles.Get("label").CalcSize(content); GUI.Label(new Rect(cone.position + Vector2.one * 10, size), content); } } { if (_type.HasFlag(LineType.Y_Speed)) { var point = _curve.GetPercent(_percent); var p2 = _curve.GetPercent(_percent + _curve.step); Rect cone = new Rect(Vector2.zero, Vector2.one * 10); cone.center = new Vector2(_percent * pixels, pos.height - ((p2 - point).y / _curve.step) * pixels) + pos.position; GUI.Box(cone, new GUIContent("", point.ToString()), GUIStyles.Get("U2D.createRect")); var content = new GUIContent(point.ToString()); var size = GUIStyles.Get("label").CalcSize(content); GUI.Label(new Rect(cone.position + Vector2.one * 10, size), content); } } } var rect = new Rect(pos.BottomLeft() + new Vector2(0, 30), new Vector2(pos.width, 20)); var rs = rect.VerticalSplit(pos.width / 4 * 3, 20); using (new EditorGUI.DisabledScope(_curve == null)) { _percent = EditorGUI.Slider(rs[0], "Percent", _percent, 0, 1); if (GUI.Button(rs[1], "Watch Curve")) { _percent = 0; if (tween != null) { tween.Complete(false); tween = null; } tween = TweenEx.DoGoto(0, 1, 5f, () => { return(_percent); }, (value) => { _percent = value; window.Repaint(); }, false, EditorEnv.envType) .SetCurve(_curve) .OnCompelete(() => { _percent = 1; }) .SetDeltaTime((float)EditorEnv.env.deltaTime.TotalMilliseconds); } } GUI.EndGroup(); }
public override void OnInspectorGUI() { style = GUIStyles.Get("foldout"); style.overflow = new RectOffset(-10, 0, 3, 0); style.padding = new RectOffset(25, 0, -3, 0); serializedObject.Update(); if (!initialized) { for (var i = 0; i < length; i++) { var fold = Attribute.GetCustomAttribute(objectFields[i], typeof(FoldoutAttribute)) as FoldoutAttribute; Cache c; if (fold == null) { if (prevFold != null && prevFold.foldEverything) { if (!cache.TryGetValue(prevFold.name, out c)) { cache.Add(prevFold.name, new Cache { atr = prevFold, types = new HashSet <string> { objectFields[i].Name } }); } else { c.types.Add(objectFields[i].Name); } } continue; } prevFold = fold; if (!cache.TryGetValue(fold.name, out c)) { cache.Add(fold.name, new Cache { atr = fold, types = new HashSet <string> { objectFields[i].Name } }); } else { c.types.Add(objectFields[i].Name); } } var property = serializedObject.GetIterator(); var next = property.NextVisible(true); if (next) { do { index++; HandleProp(property, index); } while (property.NextVisible(false)); } } if (orders.Count == 0) { DrawDefaultInspector(); return; } initialized = true; using (new EditorGUI.DisabledScope("m_Script" == orders[0].prop.propertyPath)) { EditorGUILayout.PropertyField(orders[0].prop, true); } EditorGUILayout.Space(); for (int i = 1; i < orders.Count; i++) { var order = orders[i]; if (order.prop != null) { EditorGUILayout.PropertyField(order.prop, true); } else { RenderCache(cache[order.cacheID]); } } serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); }