public override void OnInspectorGUI() { NSTSampleHealthUI _target = (NSTSampleHealthUI)target; IVitals ivitals = null; base.OnInspectorGUI(); EditorGUILayout.HelpBox("This component should be placed on a UI Text or UI Image (with Image Type set to Filled ideally). " + "It can monitor IVitals on the root of this object, or of the local player gameobject.", MessageType.None); string monitorTooltip = "Which IVital should be be monitoring? Auto will try to find an IVital interface on the root of this object first, and if it can't find one will subscribe to the local player IVital."; _target.monitor = (NSTSampleHealthUI.Monitor)EditorGUILayout.EnumPopup(new GUIContent("IVitals Source", monitorTooltip), _target.monitor); bool monitorSelf = _target.monitor == NSTSampleHealthUI.Monitor.Self; bool monitorLclPlayer = _target.monitor == NSTSampleHealthUI.Monitor.LocalPlayer; // if monitoring self is an option, try to take it - see if we have vitals if (!monitorLclPlayer) { ivitals = _target.transform.root.GetComponent <IVitals>(); } // failed to find vitals or we are only set to monitor the local player if (ivitals == null && !monitorSelf) { // make the GO selector available if no vitals were found on this object string gotooltip = "Used by the editor only. Vital names in the list below are pulled from the IVitals on this gameobject."; _target.vitalsSrcGO = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Player GameObj", gotooltip), _target.vitalsSrcGO, typeof(GameObject), true); if (_target.vitalsSrcGO == null) { if (MasterNetAdapter.NetLib == NetworkLibrary.UNET) { _target.vitalsSrcGO = MasterNetAdapter.UNET_GetRegisteredPlayerPrefab(); } else if (MasterNetAdapter.NetLib == NetworkLibrary.PUN) { _target.vitalsSrcGO = PUNSampleLauncher.Single.playerPrefab; } } if (_target.vitalsSrcGO != null) { ivitals = _target.vitalsSrcGO.GetComponent <IVitals>(); } } int i = 0; // if we found an iVitals... scrape out the names if (ivitals != null) { for (i = 0; i < ivitals.Vitals.Count; i++) { vitalnames[i] = (new GUIContent(i.ToString() + " " + ivitals.Vitals[i].name)); } } // if not, just make a list of numbers for (int j = i; j < 16; j++) { vitalnames[j] = (new GUIContent(j.ToString())); } string vitalIdTooltip = "Which vital to monitor."; GUIContent label = new GUIContent("Monitored Vital", vitalIdTooltip); _target.monitoredVitalId = EditorGUILayout.Popup(label, _target.monitoredVitalId, vitalnames); serializedObject.ApplyModifiedProperties(); }
// TODO: Need none in the popup to clear a channel public override void OnInspectorGUI() { MegaMorphLink anim = (MegaMorphLink)target; anim.morph = (MegaMorph)EditorGUILayout.ObjectField("Morph", anim.morph, typeof(MegaMorph), true); MegaMorph morph = anim.morph; //gameObject.GetComponent<MegaMorph>(); if (morph != null) { if (GUILayout.Button("Add Link")) { MegaMorphLinkDesc desc = new MegaMorphLinkDesc(); anim.links.Add(desc); } string[] channels = morph.GetChannelNames(); for (int i = 0; i < anim.links.Count; i++) { MegaMorphLinkDesc md = anim.links[i]; md.name = EditorGUILayout.TextField("Name", md.name); //md.active = EditorGUILayout.Toggle("Active", md.active); //if ( md.active ) md.active = EditorGUILayout.BeginToggleGroup("Active", md.active); { md.channel = EditorGUILayout.Popup("Channel", md.channel, channels); md.target = (Transform)EditorGUILayout.ObjectField("Target", md.target, typeof(Transform), true); md.src = (MegaLinkSrc)EditorGUILayout.EnumPopup("Source", md.src); if (md.src != MegaLinkSrc.Angle && md.src != MegaLinkSrc.DotRotation) { md.axis = (MegaAxis)EditorGUILayout.EnumPopup("Axis", md.axis); } EditorGUILayout.LabelField("Val", md.GetVal().ToString()); md.min = EditorGUILayout.FloatField("Min", md.min); md.max = EditorGUILayout.FloatField("Max", md.max); md.low = EditorGUILayout.FloatField("Low", md.low); md.high = EditorGUILayout.FloatField("High", md.high); md.useCurve = EditorGUILayout.BeginToggleGroup("Use Curve", md.useCurve); md.curve = EditorGUILayout.CurveField("Curve", md.curve); EditorGUILayout.EndToggleGroup(); if (md.src == MegaLinkSrc.Angle || md.src == MegaLinkSrc.DotRotation) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set Start Rot")) { if (md.target) { md.rot = md.target.localRotation; } } //if ( GUILayout.Button("Set End Rot") ) //{ //if ( md.target ) //{ //Quaternion rot = md.target.localRotation; // md.max = md.GetVal(); //} //} EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set Min Val")) { if (md.target) { md.min = md.GetVal(); } //md.rot = md.target.localRotation; } if (GUILayout.Button("Set Max Val")) { if (md.target) { //Quaternion rot = md.target.localRotation; md.max = md.GetVal(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); if (GUILayout.Button("Delete")) { anim.links.RemoveAt(i); i--; } } if (GUI.changed) { EditorUtility.SetDirty(target); } } }
/// <summary> /// Draw the inspector widget. /// </summary> protected override bool ShouldDrawProperties() { float alpha = EditorGUILayout.Slider("Alpha", mPanel.alpha, 0f, 1f); if (alpha != mPanel.alpha) { NGUIEditorTools.RegisterUndo("Panel Alpha", mPanel); mPanel.alpha = alpha; } GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Depth"); int depth = mPanel.depth; if (GUILayout.Button("Back", GUILayout.Width(60f))) { --depth; } depth = EditorGUILayout.IntField(depth, GUILayout.MinWidth(20f)); if (GUILayout.Button("Forward", GUILayout.Width(68f))) { ++depth; } if (mPanel.depth != depth) { NGUIEditorTools.RegisterUndo("Panel Depth", mPanel); mPanel.depth = depth; if (UIPanelTool.instance != null) { UIPanelTool.instance.Repaint(); } if (UIDrawCallViewer.instance != null) { UIDrawCallViewer.instance.Repaint(); } } } GUILayout.EndHorizontal(); int matchingDepths = 0; for (int i = 0, imax = UIPanel.list.Count; i < imax; ++i) { UIPanel p = UIPanel.list[i]; if (p != null && mPanel.depth == p.depth) { ++matchingDepths; } } if (matchingDepths > 1) { EditorGUILayout.HelpBox(matchingDepths + " panels are sharing the depth value of " + mPanel.depth, MessageType.Warning); } UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", mPanel.clipping); if (mPanel.clipping != clipping) { mPanel.clipping = clipping; EditorUtility.SetDirty(mPanel); } // Contributed by Benzino07: http://www.tasharen.com/forum/index.php?topic=6956.15 GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Sorting Layer"); // Get the names of the Sorting layers System.Type internalEditorUtilityType = typeof(InternalEditorUtility); PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic); string[] names = (string[])sortingLayersProperty.GetValue(null, new object[0]); int index = 0; if (!string.IsNullOrEmpty(mPanel.sortingLayerName)) { for (int i = 0; i < names.Length; i++) { if (mPanel.sortingLayerName == names[i]) { index = i; break; } } } // Get the selected index and update the panel sorting layer if it has changed int selectedIndex = EditorGUILayout.Popup(index, names); if (index != selectedIndex) { mPanel.sortingLayerName = names[selectedIndex]; EditorUtility.SetDirty(mPanel); } } GUILayout.EndHorizontal(); if (mPanel.clipping != UIDrawCall.Clipping.None) { Vector4 range = mPanel.baseClipRegion; // Scroll view is anchored, meaning it adjusts the offset itself, so we don't want it to be modifiable //EditorGUI.BeginDisabledGroup(mPanel.GetComponent<UIScrollView>() != null); GUI.changed = false; GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector3 off = EditorGUILayout.Vector2Field("Offset", mPanel.clipOffset, GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (GUI.changed) { NGUIEditorTools.RegisterUndo("Clipping Change", mPanel); mPanel.clipOffset = off; EditorUtility.SetDirty(mPanel); } //EditorGUI.EndDisabledGroup(); GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y), GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w), GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (size.x < 0f) { size.x = 0f; } if (size.y < 0f) { size.y = 0f; } range.x = pos.x; range.y = pos.y; range.z = size.x; range.w = size.y; if (mPanel.baseClipRegion != range) { NGUIEditorTools.RegisterUndo("Clipping Change", mPanel); mPanel.baseClipRegion = range; EditorUtility.SetDirty(mPanel); } if (mPanel.clipping == UIDrawCall.Clipping.SoftClip) { GUILayout.BeginHorizontal(); GUILayout.Space(80f); Vector2 soft = EditorGUILayout.Vector2Field("Softness", mPanel.clipSoftness, GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (soft.x < 0f) { soft.x = 0f; } if (soft.y < 0f) { soft.y = 0f; } if (mPanel.clipSoftness != soft) { NGUIEditorTools.RegisterUndo("Clipping Change", mPanel); mPanel.clipSoftness = soft; EditorUtility.SetDirty(mPanel); } } else if (mPanel.clipping == UIDrawCall.Clipping.TextureMask) { NGUIEditorTools.SetLabelWidth(0f); GUILayout.Space(-90f); Texture2D tex = (Texture2D)EditorGUILayout.ObjectField(mPanel.clipTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(70f)); GUILayout.Space(20f); if (mPanel.clipTexture != tex) { NGUIEditorTools.RegisterUndo("Clipping Change", mPanel); mPanel.clipTexture = tex; EditorUtility.SetDirty(mPanel); } NGUIEditorTools.SetLabelWidth(80f); } } if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(mPanel.transform.lossyScale)) { EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error); if (GUILayout.Button("Auto-fix")) { NGUIEditorTools.FixUniform(mPanel.gameObject); } } if (NGUIEditorTools.DrawHeader("Advanced Options")) { NGUIEditorTools.BeginContents(); GUILayout.BeginHorizontal(); UIPanel.RenderQueue rq = (UIPanel.RenderQueue)EditorGUILayout.EnumPopup("Render Q", mPanel.renderQueue); if (mPanel.renderQueue != rq) { mPanel.renderQueue = rq; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); if (UIDrawCallViewer.instance != null) { UIDrawCallViewer.instance.Repaint(); } } if (rq != UIPanel.RenderQueue.Automatic) { int sq = EditorGUILayout.IntField(mPanel.startingRenderQueue, GUILayout.Width(40f)); if (mPanel.startingRenderQueue != sq) { mPanel.startingRenderQueue = sq; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); if (UIDrawCallViewer.instance != null) { UIDrawCallViewer.instance.Repaint(); } } } GUILayout.EndHorizontal(); GUI.changed = false; // --==GAM==-- //int so = EditorGUILayout.IntField("Sort Order", mPanel.sortingOrder, GUILayout.Width(120f)); //if (GUI.changed) mPanel.sortingOrder = so; if (Application.isPlaying) { int so = EditorGUILayout.IntField("Sort Order", mPanel.sortingOrder, GUILayout.Width(120f)); if (GUI.changed) { mPanel.sortingOrder = so; } } else { SortingOrder soEnum = (SortingOrder)EditorGUILayout.EnumPopup("Sort Order", (SortingOrder)mPanel.sortingOrder); if (GUI.changed) { mPanel.sortingOrder = (int)soEnum; } } // --==GAM==-- GUILayout.BeginHorizontal(); bool norms = EditorGUILayout.Toggle("Normals", mPanel.generateNormals, GUILayout.Width(100f)); GUILayout.Label("Needed for lit shaders", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (mPanel.generateNormals != norms) { mPanel.generateNormals = norms; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); } GUILayout.BeginHorizontal(); bool cull = EditorGUILayout.Toggle("Cull", mPanel.cullWhileDragging, GUILayout.Width(100f)); GUILayout.Label("Cull widgets while dragging them", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (mPanel.cullWhileDragging != cull) { mPanel.cullWhileDragging = cull; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); } GUILayout.BeginHorizontal(); bool alw = EditorGUILayout.Toggle("Visible", mPanel.alwaysOnScreen, GUILayout.Width(100f)); GUILayout.Label("Check if widgets never go off-screen", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (mPanel.alwaysOnScreen != alw) { mPanel.alwaysOnScreen = alw; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); } GUILayout.BeginHorizontal(); NGUIEditorTools.DrawProperty("Padding", serializedObject, "softBorderPadding", GUILayout.Width(100f)); GUILayout.Label("Soft border pads content", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(mPanel.GetComponent <UIRoot>() != null); bool off = EditorGUILayout.Toggle("Offset", mPanel.anchorOffset && mPanel.GetComponent <UIRoot>() == null, GUILayout.Width(100f)); GUILayout.Label("Offset anchors by position", GUILayout.MinWidth(20f)); EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); if (mPanel.anchorOffset != off) { mPanel.anchorOffset = off; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); } GUILayout.BeginHorizontal(); bool stat = EditorGUILayout.Toggle("Static", mPanel.widgetsAreStatic, GUILayout.Width(100f)); GUILayout.Label("Check if widgets won't move", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); if (mPanel.widgetsAreStatic != stat) { mPanel.widgetsAreStatic = stat; mPanel.RebuildAllDrawCalls(); EditorUtility.SetDirty(mPanel); } if (stat) { EditorGUILayout.HelpBox("Only mark the panel as 'static' if you know FOR CERTAIN that the widgets underneath will not move, rotate, or scale. Doing this improves performance, but moving widgets around will have no effect.", MessageType.Warning); } GUILayout.BeginHorizontal(); bool tool = EditorGUILayout.Toggle("Panel Tool", mPanel.showInPanelTool, GUILayout.Width(100f)); GUILayout.Label("Show in panel tool"); GUILayout.EndHorizontal(); if (mPanel.showInPanelTool != tool) { mPanel.showInPanelTool = !mPanel.showInPanelTool; EditorUtility.SetDirty(mPanel); EditorWindow.FocusWindowIfItsOpen <UIPanelTool>(); } NGUIEditorTools.EndContents(); } return(true); }
public override void ShowGUI(MenuSource source) { EditorGUILayout.BeginVertical("Button"); fixedOption = EditorGUILayout.Toggle("Fixed option number?", fixedOption); if (fixedOption) { numSlots = 1; slotSpacing = 0f; optionToShow = EditorGUILayout.IntField("Option to display:", optionToShow); } else { maxSlots = EditorGUILayout.IntField("Max no. of slots:", maxSlots); if (source == MenuSource.AdventureCreator) { numSlots = EditorGUILayout.IntSlider("Test slots:", numSlots, 1, maxSlots); slotSpacing = EditorGUILayout.Slider("Slot spacing:", slotSpacing, 0f, 20f); orientation = (ElementOrientation)EditorGUILayout.EnumPopup("Slot orientation:", orientation); if (orientation == ElementOrientation.Grid) { gridWidth = EditorGUILayout.IntSlider("Grid size:", gridWidth, 1, 10); } } } if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor); textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects); } displayType = (SaveDisplayType)EditorGUILayout.EnumPopup("Display:", displayType); if (displayType != SaveDisplayType.LabelOnly) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Empty slot texture:", GUILayout.Width(145f)); blankSlotTexture = (Texture2D)EditorGUILayout.ObjectField(blankSlotTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); } saveListType = (AC_SaveListType)EditorGUILayout.EnumPopup("List type:", saveListType); if (saveListType == AC_SaveListType.Save) { showNewSaveOption = EditorGUILayout.Toggle("Show 'New save' option?", showNewSaveOption); if (showNewSaveOption) { newSaveText = EditorGUILayout.TextField("'New save' text:", newSaveText); } autoHandle = EditorGUILayout.Toggle("Save when click on?", autoHandle); if (autoHandle) { ActionListGUI("ActionList after saving:"); } else { ActionListGUI("ActionList when click:"); } } else if (saveListType == AC_SaveListType.Load) { autoHandle = EditorGUILayout.Toggle("Load when click on?", autoHandle); if (autoHandle) { ActionListGUI("ActionList after loading:"); } else { ActionListGUI("ActionList when click:"); } } else if (saveListType == AC_SaveListType.Import) { autoHandle = true; #if UNITY_STANDALONE importProductName = EditorGUILayout.TextField("Import project name:", importProductName); importSaveFilename = EditorGUILayout.TextField("Import save filename:", importSaveFilename); ActionListGUI("ActionList after import:"); checkImportBool = EditorGUILayout.Toggle("Require Bool to be true?", checkImportBool); if (checkImportBool) { checkImportVar = EditorGUILayout.IntField("Global Variable ID:", checkImportVar); } #else EditorGUILayout.HelpBox("This feature is only available for standalone platforms (PC, Mac, Linux)", MessageType.Warning); #endif } if (source != MenuSource.AdventureCreator) { EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); uiHideStyle = (UIHideStyle)EditorGUILayout.EnumPopup("When invisible:", uiHideStyle); EditorGUILayout.LabelField("Linked button objects", EditorStyles.boldLabel); if (fixedOption) { uiSlots = ResizeUISlots(uiSlots, 1); } else { uiSlots = ResizeUISlots(uiSlots, maxSlots); } for (int i = 0; i < uiSlots.Length; i++) { uiSlots[i].LinkedUiGUI(i, source); } } EditorGUILayout.EndVertical(); base.ShowGUI(source); }
private void OnGUI() { if (GUILayout.Button("Read Raws")) { var client = new RemoteClient(); if (!client.Connect()) { return; } client.SuspendGame(); var getCreatureRaws = new RemoteFunction <EmptyMessage, CreatureRawList>(client, "GetCreatureRaws", "RemoteFortressReader"); var materialListCall = new RemoteFunction <EmptyMessage, MaterialList>(client, "GetMaterialList", "RemoteFortressReader"); var itemListCall = new RemoteFunction <EmptyMessage, MaterialList>(client, "GetItemList", "RemoteFortressReader"); var unitListCall = new RemoteFunction <EmptyMessage, UnitList>(client, "GetUnitList", "RemoteFortressReader"); client.ResumeGame(); MaterialRaws.Instance.MaterialList = materialListCall.Execute().material_list; ItemRaws.Instance.ItemList = itemListCall.Execute().material_list; CreatureRaws.Instance.CreatureList = getCreatureRaws.Execute().creature_raws; units = unitListCall.Execute().creature_list; AssetDatabase.SaveAssets(); Debug.Log(string.Format("Pulled {0} creature raws from DF.", CreatureRaws.Instance.Count)); if (MaterialCollection.Instance == null) { MaterialCollector.BuildMaterialCollection(); } MaterialCollection.Instance.PopulateMatTextures(); client.Disconnect(); //foreach (var raw in CreatureRaws.Instance) //{ // raw.creature_id = BodyDefinition.GetCorrectedCreatureID(raw); //} RefilterList(); } if (CreatureRaws.Instance.Count == 0) { if (filteredRaws != null) { filteredRaws.Clear(); } if (units != null) { units.Clear(); } } if (CreatureRaws.Instance.Count > 0) { EditorGUI.BeginChangeCheck(); filter = EditorGUILayout.TextField(filter); filterToken = EditorGUILayout.Toggle("Token", filterToken); filterName = EditorGUILayout.Toggle("Name", filterName); filterDescription = EditorGUILayout.Toggle("Description", filterDescription); filterParts = EditorGUILayout.Toggle("Parts", filterParts); bodyCategoryFilter = (CreatureBody.BodyCategory)EditorGUILayout.EnumPopup(bodyCategoryFilter); if (EditorGUI.EndChangeCheck() || filteredRaws == null) { RefilterList(); } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); //if(GUILayout.Button("Sort by name")) //{ // CreatureRaws.Instance.Sort((x, y) => x.creature_id.CompareTo(y.creature_id)); // RefilterList(); //} //if (GUILayout.Button("Sort by size")) //{ // CreatureRaws.Instance.Sort((x, y) => x.adultsize.CompareTo(y.adultsize)); // RefilterList(); //} //if (GUILayout.Button("Sort by index")) //{ // CreatureRaws.Instance.Sort((x, y) => x.index.CompareTo(y.index)); // RefilterList(); //} GUILayout.EndHorizontal(); if (filteredRaws != null && filteredRaws.Count > 0) { showRaces = EditorGUILayout.Foldout(showRaces, "Races"); if (showRaces) { raceScroll = EditorGUILayout.BeginScrollView(raceScroll); foreach (var creature in filteredRaws) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(string.Format("{0} ({1})", creature.creature_id, creature.name[0])); EditorGUILayout.BeginVertical(); foreach (var caste in creature.caste) { if (GUILayout.Button(string.Format("{0} ({1})", caste.caste_id, caste.caste_name[0]))) { AssetDatabase.Refresh(); var creatureBase = new GameObject().AddComponent <CreatureBody>(); creatureBase.name = caste.caste_name[0]; creatureBase.race = creature; creatureBase.caste = caste; creatureBase.MakeBody(); creatureBase.transform.localRotation = Quaternion.Euler(0, 180, 0); Selection.SetActiveObjectWithContext(creatureBase, null); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Dump Part Categories")) { var path = EditorUtility.SaveFilePanel("Save bodypart list", "", "Bodyparts.csv", "csv"); if (!string.IsNullOrEmpty(path)) { Dictionary <string, Dictionary <string, ChildCount> > parts = new Dictionary <string, Dictionary <string, ChildCount> >(); foreach (var creature in filteredRaws) { foreach (var caste in creature.caste) { if (bodyCategoryFilter != CreatureBody.BodyCategory.None && bodyCategoryFilter != CreatureBody.FindBodyCategory(caste)) { continue; } for (int i = 0; i < caste.body_parts.Count; i++) { var part = caste.body_parts[i]; //this is an internal part, and doesn't need modeling. if (part.flags[(int)BodyPartFlags.BodyPartRawFlags.INTERNAL]) { continue; } if (!parts.ContainsKey(part.category)) { parts[part.category] = new Dictionary <string, ChildCount>(); } Dictionary <string, int> childCounts = new Dictionary <string, int>(); foreach (var sub in caste.body_parts) { if (sub.parent != i) { continue; } if (sub.flags[(int)BodyPartFlags.BodyPartRawFlags.INTERNAL]) { continue; } if (!childCounts.ContainsKey(sub.category)) { childCounts[sub.category] = 1; } else { childCounts[sub.category]++; } } foreach (var item in childCounts) { if (!parts[part.category].ContainsKey(item.Key)) { parts[part.category][item.Key] = new ChildCount(); } if (parts[part.category][item.Key].min > item.Value) { parts[part.category][item.Key].min = item.Value; } if (parts[part.category][item.Key].max < item.Value) { parts[part.category][item.Key].max = item.Value; } } } } } using (var writer = new StreamWriter(path)) { foreach (var parent in parts) { writer.Write("\"" + parent.Key + "\","); foreach (var child in parent.Value) { writer.Write(string.Format("\"{0}\",{1},{2},", child.Key, child.Value.min, child.Value.max)); } writer.WriteLine(); } } } } if (GUILayout.Button("Place all races")) { AssetDatabase.Refresh(); var watch = System.Diagnostics.Stopwatch.StartNew(); CreatureBody prevCreature = null; foreach (var creature in filteredRaws) { var creatureBase = new GameObject().AddComponent <CreatureBody>(); creatureBase.name = creature.caste[0].caste_name[0]; creatureBase.race = creature; creatureBase.caste = creature.caste[0]; creatureBase.MakeBody(); if (prevCreature != null) { creatureBase.transform.position = new Vector3(prevCreature.transform.position.x + prevCreature.bounds.max.x - creatureBase.bounds.min.x, 0, 0); } creatureBase.transform.localRotation = Quaternion.Euler(0, 180, 0); prevCreature = creatureBase; } watch.Stop(); Debug.Log(string.Format("Took {0}ms to create {1} creatures, averaging {2}ms per creature.", watch.ElapsedMilliseconds, filteredRaws.Count, (float)watch.ElapsedMilliseconds / filteredRaws.Count)); } } } if (units != null && units.Count > 0) { showUnits = EditorGUILayout.Foldout(showUnits, "Units"); if (showUnits) { unitScroll = EditorGUILayout.BeginScrollView(unitScroll); foreach (var unit in units) { if (!CreatureManager.IsValidCreature(unit)) { continue; } string name = unit.name; if (string.IsNullOrEmpty(name)) { name = CreatureRaws.Instance[unit.race.mat_type].caste[unit.race.mat_index].caste_name[0]; } if (!FitsFilter(unit)) { continue; } if (GUILayout.Button(name)) { AssetDatabase.Refresh(); var creatureBase = new GameObject().AddComponent <CreatureBody>(); creatureBase.name = name; creatureBase.race = CreatureRaws.Instance[unit.race.mat_type]; creatureBase.caste = CreatureRaws.Instance[unit.race.mat_type].caste[unit.race.mat_index]; creatureBase.unit = unit; creatureBase.MakeBody(); creatureBase.UpdateUnit(unit); creatureBase.transform.localRotation = Quaternion.Euler(0, 180, 0); Selection.SetActiveObjectWithContext(creatureBase, null); } } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Place all units")) { AssetDatabase.Refresh(); var watch = System.Diagnostics.Stopwatch.StartNew(); CreatureBody prevCreature = null; int creatureCount = 0; foreach (var unit in units) { if (!CreatureManager.IsValidCreature(unit)) { continue; } string name = unit.name; if (string.IsNullOrEmpty(name)) { name = CreatureRaws.Instance[unit.race.mat_type].caste[unit.race.mat_index].caste_name[0]; } if (!FitsFilter(unit)) { continue; } var creatureBase = new GameObject().AddComponent <CreatureBody>(); creatureBase.name = name; creatureBase.race = CreatureRaws.Instance[unit.race.mat_type]; creatureBase.caste = CreatureRaws.Instance[unit.race.mat_type].caste[unit.race.mat_index]; creatureBase.unit = unit; creatureBase.MakeBody(); creatureBase.UpdateUnit(unit); creatureBase.transform.localRotation = Quaternion.Euler(0, 180, 0); if (prevCreature != null) { creatureBase.transform.position = new Vector3(prevCreature.transform.position.x + prevCreature.bounds.max.x - creatureBase.bounds.min.x, 0, 0); } prevCreature = creatureBase; creatureCount++; } watch.Stop(); Debug.Log(string.Format("Took {0}ms to create {1} creatures, averaging {2}ms per creature.", watch.ElapsedMilliseconds, creatureCount, (float)watch.ElapsedMilliseconds / creatureCount)); } } } } }
void OnGUI() { if (Application.unityVersion[0] >= '5') { EditorGUILayout.Space(); } inspector = InspectorNavigator.Instance; if (inspector == null) { InspectorNavigator.OpenWindow(); inspector = InspectorNavigator.Instance; } #if FULL_VERSION EditorGUILayout.LabelField("Inspector Navigator Version " + InspectorNavigator.CurrentVersion / 100 + "." + (InspectorNavigator.CurrentVersion % 100).ToString("00") + " [Full]", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); if (GUILayout.Button("Edit Navigator Key Bindings")) { EditKeyBindings(inspector); } EditorGUILayout.Space(); inspector.MaxEnqueuedObjects = EditorGUILayout.IntField(new GUIContent("Max. enqueued objects", "Max. number of objects on Back/Forward queues"), inspector.MaxEnqueuedObjects); if (inspector.MaxEnqueuedObjects < 8) { inspector.MaxEnqueuedObjects = 8; } else if (inspector.MaxEnqueuedObjects > 512) { inspector.MaxEnqueuedObjects = 512; } inspector.MaxLabelWidth = EditorGUILayout.IntField(new GUIContent("Max. label width", "Maximum object label width in pixels (0: full)"), inspector.MaxLabelWidth); if (inspector.MaxLabelWidth < 0) { inspector.MaxLabelWidth = 0; } else if (inspector.MaxLabelWidth > 0 && inspector.MaxLabelWidth < 20) { inspector.MaxLabelWidth = 20; } if (EditorGUI.EndChangeCheck()) { inspector.Repaint(); } EditorGUI.BeginChangeCheck(); inspector.BarAlignment = (BarAlignment)EditorGUILayout.EnumPopup(new GUIContent("Bar alignment", "Set horizontal breadcrumb alignment preference"), inspector.BarAlignment); if (EditorGUI.EndChangeCheck()) { inspector.Repaint(); } inspector.InsertNewObjects = EditorGUILayout.Toggle(new GUIContent("Insert new objects", "Insert objects, instead of clearing forward list"), inspector.InsertNewObjects); EditorGUI.BeginChangeCheck(); inspector.RemoveUnnamedObjects = EditorGUILayout.Toggle(new GUIContent("Remove unnamed objs", "Remove breadcrumbs with no name"), inspector.RemoveUnnamedObjects); if (EditorGUI.EndChangeCheck() && inspector.RemoveUnnamedObjects) { inspector.Repaint(); } var prevDupBehaviour = inspector.DuplicatesBehavior; inspector.DuplicatesBehavior = (DuplicatesBehavior)EditorGUILayout.EnumPopup(new GUIContent("Duplicated Objects", "What to do with duplicated objects"), inspector.DuplicatesBehavior); if (inspector.DuplicatesBehavior != prevDupBehaviour && inspector.DuplicatesBehavior == DuplicatesBehavior.RemoveAllDuplicates) { inspector.ClearDuplicates(); inspector.Repaint(); } inspector.CameraBehavior = (CameraBehavior)EditorGUILayout.EnumPopup(new GUIContent("Scene camera behavior", "What to do with the scene camera"), inspector.CameraBehavior); inspector.CheckForUpdates = EditorGUILayout.Toggle(new GUIContent("Check for updates", "Check if there's a new version"), inspector.CheckForUpdates); inspector.OtherNotifications = EditorGUILayout.Toggle(new GUIContent("Other notifications", "Show other wasabimole notifications"), inspector.OtherNotifications); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); GUI.enabled = inspector.SerializeBreadcrumbs = EditorGUILayout.ToggleLeft(new GUIContent("Save InspectorBreadcrumbs as a scene object", "Serialize InspectorBreadcrumbs in every scene"), inspector.SerializeBreadcrumbs); if (EditorGUI.EndChangeCheck()) { inspector.SetBreadcrumbsProperties(); if (!inspector.SerializeBreadcrumbs && Event.current.type == EventType.Used) { if (EditorUtility.DisplayDialog("Remove breadcrumbs from all of your project scenes?", "Would you like to remove the Inspector Navigator's breadcrumbs object from all your existing project scenes? (might take a while if you have many big scenes)", "Yes, clean all scenes", "No, cancel")) { InspectorNavigator.ClearAllProjectBreadcrumbs(); } } } var showBC = inspector.ShowBreadcrumbsObject; EditorGUILayout.BeginHorizontal(); GUILayout.Space(18); inspector.ShowBreadcrumbsObject = EditorGUILayout.Toggle(new GUIContent("Show breadcrumbs obj", "Show breadcrumbs object in scene"), inspector.ShowBreadcrumbsObject); EditorGUILayout.EndHorizontal(); if (showBC != inspector.ShowBreadcrumbsObject) { inspector.SetBreadcrumbsProperties(); } EditorGUILayout.BeginHorizontal(); GUILayout.Space(18); inspector.ForceDirty = EditorGUILayout.Toggle(new GUIContent("Mark scene as changed", "New selections mark scene as changed"), inspector.ForceDirty); EditorGUILayout.EndHorizontal(); GUI.enabled = true; EditorGUILayout.Space(); EditorGUILayout.LabelField("Object filters (inspectors to track):", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorInstance = EditorGUILayout.ColorField(inspector.ColorInstance, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackObjects = EditorGUILayout.ToggleLeft("Track scene GameObjects", inspector.TrackObjects); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorAsset = EditorGUILayout.ColorField(inspector.ColorAsset, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackAssets = EditorGUILayout.ToggleLeft("Track project Assets", inspector.TrackAssets); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorTextAssets = EditorGUILayout.ColorField(inspector.ColorTextAssets, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackTextAssets = EditorGUILayout.ToggleLeft("Track Scripts & TextAssets", inspector.TrackTextAssets); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorFolder = EditorGUILayout.ColorField(inspector.ColorFolder, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackFolders = EditorGUILayout.ToggleLeft("Track project Folders", inspector.TrackFolders); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorScene = EditorGUILayout.ColorField(inspector.ColorScene, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackScenes = EditorGUILayout.ToggleLeft("Track project Scenes", inspector.TrackScenes); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorProjectSettings = EditorGUILayout.ColorField(inspector.ColorProjectSettings, GUILayout.Width(32)); EditorGUILayout.Space(); #if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6) EditorGUI.BeginChangeCheck(); #endif inspector.TrackProjectSettings = EditorGUILayout.ToggleLeft("Track project Settings", inspector.TrackProjectSettings); #if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6) if (EditorGUI.EndChangeCheck() && inspector.TrackProjectSettings && Event.current.type == EventType.Used) { if (!EditorUtility.DisplayDialog("Enable tracking Project Settings inspectors?", "A few users reported problems on builds after having the Inspector Navigator's breadcrumbs pointing to Project Settings on Unity 4.X, are you sure you want to track settings objects?\n\nNote: You can also use the navigator's menu option \"Clear all project breadcrumbs\" to delete all the breadcrumbs from your project scenes before performing a build.", "Yes, track settings", "No, cancel")) { inspector.TrackProjectSettings = false; } } #endif EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); inspector.ColorAssetStoreInspector = EditorGUILayout.ColorField(inspector.ColorAssetStoreInspector, GUILayout.Width(32)); EditorGUILayout.Space(); inspector.TrackAssetStoreInspector = EditorGUILayout.ToggleLeft("Track Asset Store Inspector", inspector.TrackAssetStoreInspector); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { inspector.RemoveFilteredObjects(); } #else EditorGUILayout.LabelField("Inspector Navigator Version " + InspectorNavigator.CurrentVersion / 100 + "." + (InspectorNavigator.CurrentVersion % 100).ToString("00") + " [Trial]", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Default options can not be changed on trial version", MessageType.Warning); EditorGUILayout.Space(); if (GUILayout.Button("Upgrade to full version")) { NotificationWindow.OpenAssetStore("content/26181"); } EditorGUILayout.Space(); GUI.enabled = false; GUILayout.Button("Edit Navigator Key Bindings"); EditorGUILayout.Space(); EditorGUILayout.IntField(new GUIContent("Max. enqueued objects", "Max. number of objects on Back/Forward queues"), 64); EditorGUILayout.IntField(new GUIContent("Max. label width", "Maximum object label width in pixels (0: full)"), 0); EditorGUILayout.EnumPopup(new GUIContent("Bar alignment", "Set horizontal breadcrumb alignment preference"), BarAlignment.Right); EditorGUILayout.Toggle(new GUIContent("Insert new objects", "Insert objects, instead of clearing forward list"), false); EditorGUILayout.Toggle(new GUIContent("Remove unnamed objs", "Remove breadcrumbs with no name"), false); EditorGUILayout.EnumPopup(new GUIContent("Duplicated Objects", "What to do with duplicated objects"), DuplicatesBehavior.RemoveWhenLocked); EditorGUILayout.EnumPopup(new GUIContent("Scene camera behavior", "What to do with the scene camera"), CameraBehavior.RestorePreviousCamera); EditorGUILayout.Toggle(new GUIContent("Check for updates", "Check if there's a new version"), true); EditorGUILayout.Toggle(new GUIContent("Other notifications", "Show other wasabimole notifications"), true); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft(new GUIContent("Save InspectorBreadcrumbs as a scene object", "Serialize InspectorBreadcrumbs in every scene"), true); EditorGUILayout.BeginHorizontal(); GUILayout.Space(18); EditorGUILayout.Toggle(new GUIContent("Show breadcrumbs obj", "Show breadcrumbs object in scene"), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(18); EditorGUILayout.Toggle(new GUIContent("Mark scene as changed", "New selections mark scene as changed"), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Object filters (inspectors to track):", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track scene GameObjects", true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track project Assets", true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track Scripts & TextAssets", false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track project Folders", false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track project Scenes", false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track project Settings", false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.ColorField(Color.white, GUILayout.Width(32)); EditorGUILayout.Space(); EditorGUILayout.ToggleLeft("Track AssetStore assets", false); EditorGUILayout.EndHorizontal(); GUI.enabled = true; #endif EditorGUILayout.Space(); if (GUILayout.Button("Help / F.A.Q.")) { Application.OpenURL(" http://www.wasabimole.com/inspector-navigator"); } if (GUILayout.Button("Visit website")) { Application.OpenURL("http://wasabimole.com"); } EditorGUILayout.Space(); if (logo == null) { logo = new Texture2D(1, 1, TextureFormat.ARGB32, false); logo.LoadImage(System.Convert.FromBase64String(dataLogo)); logo.Apply(); logo.hideFlags = HideFlags.HideAndDontSave; } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(logo, "Label")) { Application.OpenURL("http://wasabimole.com"); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField(" Inspector Navigator - © 2014, 2015 Wasabimole"); }
public override void OnInspectorGUI() { myTarget = (MapGenerator)target; //SerializedProperty _mySerializedTileList = _mySerializedTarget.FindProperty("tiles"); showMapProperties = EditorGUILayout.Foldout(showMapProperties, new GUIContent("Map Properties", "Set different properties fot the map generation.")); if (showMapProperties) { myTarget.width = EditorGUILayout.IntSlider(new GUIContent("Width", "Specify the width of the map"), myTarget.width, 1, 100); myTarget.height = EditorGUILayout.IntSlider(new GUIContent("Height", "Specify the height of the map"), myTarget.height, 1, 100); } showTiles = EditorGUILayout.Foldout(showTiles, new GUIContent("Tiles List", "Tiles that are used to generate the map")); if (showTiles) { _mTilesSize = myTarget.tiles.Count; for (int y = 0; y < _mTilesSize; y++) { myTarget.tiles[y].tileType = (TileType)EditorGUILayout.EnumPopup("Tile Type", myTarget.tiles[y].tileType); myTarget.tiles[y].tileTexture = (Sprite)EditorGUILayout.ObjectField(new GUIContent("Tile Texture", "Tile Texture"), myTarget.tiles[y].tileTexture, typeof(Sprite), false, null); GUILayout.Label("____________________________________________________________________________________________________________"); } if (GUILayout.Button(new GUIContent("Add new Tile", "Click to add a new tile to the list"))) { Tile newTile = new Tile(); newTile.tileType = (TileType)EditorGUILayout.EnumPopup("Tile Type", TileType.NONE); //newTile.tileType = (TileType)EditorGUILayout.EnumPopup(new GUIContent("Tile Type", "Type of selected tile"), newTile.tileType,GUIStyle.none,null); newTile.tileTexture = (Sprite)EditorGUILayout.ObjectField(new GUIContent("Tile Texture", "Tile Texture"), newTile.tileTexture, typeof(Sprite), false, null); //tiles.Add(newTile); myTarget.tiles.Add(newTile); } if (GUILayout.Button(new GUIContent("Remove Tile", "Click to remove the last tile in the list"))) { //myTarget.Invoke("RemoveTile", 0.0f); //if (tiles.Count > 0) // tiles.RemoveAt(tiles.Count - 1); if (myTarget.tiles.Count > 0) { myTarget.tiles.RemoveAt(myTarget.tiles.Count - 1); } } if (GUILayout.Button(new GUIContent("Remove All Tiles", "Click to remove all tiles in the list"))) { myTarget.tiles.Clear(); } } if (GUI.changed) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }
public override void ShowGUI(Menu menu) { MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); fixedOption = EditorGUILayout.ToggleLeft("Fixed Profile ID only?", fixedOption); if (fixedOption) { numSlots = 1; slotSpacing = 0f; optionToShow = EditorGUILayout.IntField("ID to display:", optionToShow); } else { showActive = EditorGUILayout.Toggle("Include active?", showActive); maxSlots = EditorGUILayout.IntField("Max no. of slots:", maxSlots); if (source == MenuSource.AdventureCreator) { numSlots = EditorGUILayout.IntSlider("Test slots:", numSlots, 1, maxSlots); slotSpacing = EditorGUILayout.Slider("Slot spacing:", slotSpacing, 0f, 20f); orientation = (ElementOrientation)EditorGUILayout.EnumPopup("Slot orientation:", orientation); if (orientation == ElementOrientation.Grid) { gridWidth = EditorGUILayout.IntSlider("Grid size:", gridWidth, 1, 10); } } } if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor); textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects); if (textEffects != TextEffects.None) { outlineSize = EditorGUILayout.Slider("Effect size:", outlineSize, 1f, 5f); } } autoHandle = EditorGUILayout.ToggleLeft("Switch profile when click on?", autoHandle); if (autoHandle) { ActionListGUI("ActionList after selecting:", menu.title, "After_Selecting"); } else { ActionListGUI("ActionList when click:", menu.title, "When_Click"); } if (source != MenuSource.AdventureCreator) { EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); uiHideStyle = (UIHideStyle)EditorGUILayout.EnumPopup("When invisible:", uiHideStyle); EditorGUILayout.LabelField("Linked button objects", EditorStyles.boldLabel); uiSlots = ResizeUISlots(uiSlots, maxSlots); for (int i = 0; i < uiSlots.Length; i++) { uiSlots[i].LinkedUiGUI(i, source); } } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
private void DrawImportSettings() { using (var check = new EditorGUI.ChangeCheckScope()) { showImportSettings = EditorGUILayout.Foldout(showImportSettings, labelShowImport, styleBoldFoldout); if (check.changed) { Rect window = position; int expand = 165; window.yMax += showImportSettings ? expand : -expand; position = window; } } if (showImportSettings == false) { return; } EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(importFile == null); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); DrawPathPicker(); importSettings.fileNaming = (NamingConvention)EditorGUILayout.EnumPopup(labelFileNaming, importSettings.fileNaming); if (importSettings.fileNaming != NamingConvention.LayerNameOnly) { EditorGUI.indentLevel++; importSettings.groupMode = (GroupMode)EditorGUILayout.EnumPopup(labelGrpMode, importSettings.groupMode); EditorGUI.indentLevel--; } EditorGUILayout.Space(); importSettings.PackingTag = EditorGUILayout.TextField(labelPackTag, importSettings.PackingTag); importPPU = EditorGUILayout.FloatField(labelPixelUnit, importPPU); SpriteAlignUI.DrawGUILayout(labelAlignment, importSettings.DefaultAlignment, newAlign => { importSettings.DefaultAlignment = newAlign; settingsChanged = true; ApplyDefaultSettings(); }); if (importSettings.DefaultAlignment == SpriteAlignment.Custom) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Space(EditorGUIUtility.labelWidth); importSettings.DefaultPivot = EditorGUILayout.Vector2Field(GUIContent.none, importSettings.DefaultPivot); } } importSettings.ScaleFactor = (ScaleFactor)EditorGUILayout.EnumPopup(labelScale, importSettings.ScaleFactor); //importSettings.AutoImport = EditorGUILayout.Toggle(labelAutoImport, importSettings.AutoImport); if (EditorGUI.EndChangeCheck()) { settingsChanged = true; importSettings.DefaultPivot.x = Mathf.Clamp01(importSettings.DefaultPivot.x); importSettings.DefaultPivot.y = Mathf.Clamp01(importSettings.DefaultPivot.y); ApplyDefaultSettings(); } using (new EditorGUI.DisabledGroupScope(settingsChanged == false)) { if (GUILayout.Button("Apply")) { WriteImportSettings(); } } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; }
public override void OnInspectorGUI() { m_Target = (PhotonView)this.target; bool isProjectPrefab = EditorUtility.IsPersistent(m_Target.gameObject); if (m_Target.ObservedComponents == null) { m_Target.ObservedComponents = new System.Collections.Generic.List <Component>(); } if (m_Target.ObservedComponents.Count == 0) { m_Target.ObservedComponents.Add(null); } EditorGUILayout.BeginHorizontal(); // Owner if (isProjectPrefab) { EditorGUILayout.LabelField("Owner:", "Set at runtime"); } else if (m_Target.isSceneView) { EditorGUILayout.LabelField("Owner", "Scene"); } else { PhotonPlayer owner = m_Target.owner; string ownerInfo = (owner != null) ? owner.name : "<no PhotonPlayer found>"; if (string.IsNullOrEmpty(ownerInfo)) { ownerInfo = "<no playername set>"; } EditorGUILayout.LabelField("Owner", "[" + m_Target.ownerId + "] " + ownerInfo); } // ownership requests EditorGUI.BeginDisabledGroup(Application.isPlaying); OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(m_Target.ownershipTransfer, GUILayout.Width(100)); if (own != m_Target.ownershipTransfer) { Undo.RecordObject(m_Target, "Change PhotonView Ownership Transfer"); m_Target.ownershipTransfer = own; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); // View ID if (isProjectPrefab) { EditorGUILayout.LabelField("View ID", "Set at runtime"); } else if (EditorApplication.isPlaying) { EditorGUILayout.LabelField("View ID", m_Target.viewID.ToString()); } else { int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", m_Target.viewID); if (m_Target.viewID != idValue) { Undo.RecordObject(m_Target, "Change PhotonView viewID"); m_Target.viewID = idValue; } } // Locally Controlled if (EditorApplication.isPlaying) { string masterClientHint = PhotonNetwork.isMasterClient ? "(master)" : ""; EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, m_Target.isMine); } //DrawOldObservedItem(); this.ConvertOldObservedItemToObservedList(); // ViewSynchronization (reliability) if (m_Target.synchronization == ViewSynchronization.Off) { GUI.color = Color.grey; } EditorGUILayout.PropertyField(serializedObject.FindProperty("synchronization"), new GUIContent("Observe option:")); if (m_Target.synchronization != ViewSynchronization.Off && m_Target.ObservedComponents.FindAll(item => item != null).Count == 0) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("Warning", EditorStyles.boldLabel); GUILayout.Label("Setting the synchronization option only makes sense if you observe something."); GUILayout.EndVertical(); } /*ViewSynchronization vsValue = (ViewSynchronization)EditorGUILayout.EnumPopup("Observe option:", m_Target.synchronization); * if (vsValue != m_Target.synchronization) * { * m_Target.synchronization = vsValue; * if (m_Target.synchronization != ViewSynchronization.Off && m_Target.observed == null) * { * EditorUtility.DisplayDialog("Warning", "Setting the synchronization option only makes sense if you observe something.", "OK, I will fix it."); * } * }*/ DrawSpecificTypeSerializationOptions(); GUI.color = Color.white; DrawObservedComponentsList(); // Cleanup: save and fix look if (GUI.changed) { #if !UNITY_MIN_5_3 EditorUtility.SetDirty(m_Target); #endif PhotonViewHandler.HierarchyChange(); // TODO: check if needed } GUI.color = Color.white; #if !UNITY_MIN_5_3 EditorGUIUtility.LookLikeControls(); #endif }
// ==== GUI ==== public void OnGUI() { if (EngineInstance == null) { if (FindEngine() == false) { EditorGUILayout.LabelField("Cannot find an Engine game object in the scene!"); return; } } if (!BlocksGotten) { GetBlocks(); } GUILayout.Space(10); MasterEngine engine = EngineInstance.GetComponent <MasterEngine>(); engine.lBlocksPath = EditorGUILayout.TextField("Blocks path", engine.lBlocksPath); if (GUI.changed) { UnityEditor.PrefabUtility.ReplacePrefab(engine.gameObject, UnityEditor.PrefabUtility.GetPrefabParent(engine.gameObject), ReplacePrefabOptions.ConnectToPrefab); } GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); // block list EditorGUILayout.BeginVertical(GUILayout.Width(190)); GUILayout.Space(10); // new block if (GUILayout.Button("New block", GUILayout.Width(145), GUILayout.Height(30))) { CreateBlock(); } GUILayout.Space(10); BlockListScroll = EditorGUILayout.BeginScrollView(BlockListScroll); int i = 0; int lastbutton = 0; foreach (GameObject block in Blocks) { if (block != null) { // block button if (i - 1 != lastbutton) // block space { GUILayout.Space(10); } lastbutton = i; EditorGUILayout.BeginHorizontal(); GUILayout.Label(i.ToString()); Voxel voxel = block.GetComponent <Voxel>(); // selected button if (SelectedPrefab != null && block.name == SelectedPrefab.name) { GUILayout.Box(voxel.VName, GUILayout.Width(140)); } // unselected button else if (GUILayout.Button(voxel.VName, GUILayout.Width(140))) { SelectBlock(block); } EditorGUILayout.EndHorizontal(); } i++; } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // block editor EditorGUILayout.BeginVertical(); BlockEditorScroll = EditorGUILayout.BeginScrollView(BlockEditorScroll); GUILayout.Space(20); if (SelectedBlock == null) { EditorGUILayout.LabelField("Select a block..."); } if (SelectedBlock != null) { Voxel selectedVoxel = SelectedBlock.GetComponent <Voxel>(); // name selectedVoxel.VName = EditorGUILayout.TextField("Name", selectedVoxel.VName); // id selectedVoxel.SetID((ushort)EditorGUILayout.IntField("ID", selectedVoxel.GetID())); GUILayout.Space(10); // mesh selectedVoxel.VCustomMesh = EditorGUILayout.Toggle("Custom mesh", selectedVoxel.VCustomMesh); selectedVoxel.VMesh = (Mesh)EditorGUILayout.ObjectField("Mesh", selectedVoxel.VMesh, typeof(Mesh), false); // texture if (selectedVoxel.VCustomMesh == false) { if (selectedVoxel.VTexture.Length < 6) { selectedVoxel.VTexture = new Vector2[6]; } selectedVoxel.VCustomSides = EditorGUILayout.Toggle("Define side textures", selectedVoxel.VCustomSides); if (selectedVoxel.VCustomSides) { selectedVoxel.VTexture[0] = EditorGUILayout.Vector2Field("Top ", selectedVoxel.VTexture[0]); selectedVoxel.VTexture[1] = EditorGUILayout.Vector2Field("Bottom ", selectedVoxel.VTexture[1]); selectedVoxel.VTexture[2] = EditorGUILayout.Vector2Field("Right ", selectedVoxel.VTexture[2]); selectedVoxel.VTexture[3] = EditorGUILayout.Vector2Field("Left ", selectedVoxel.VTexture[3]); selectedVoxel.VTexture[4] = EditorGUILayout.Vector2Field("Forward ", selectedVoxel.VTexture[4]); selectedVoxel.VTexture[5] = EditorGUILayout.Vector2Field("Back ", selectedVoxel.VTexture[5]); } else { selectedVoxel.VTexture[0] = EditorGUILayout.Vector2Field("Texture ", selectedVoxel.VTexture[0]); } } // rotation else { selectedVoxel.VRotation = (MeshRotation)EditorGUILayout.EnumPopup("Mesh rotation", selectedVoxel.VRotation); } GUILayout.Space(10); // material index selectedVoxel.VSubmeshIndex = EditorGUILayout.IntField("Material index", selectedVoxel.VSubmeshIndex); if (selectedVoxel.VSubmeshIndex < 0) { selectedVoxel.VSubmeshIndex = 0; } // transparency selectedVoxel.VTransparency = (Transparency)EditorGUILayout.EnumPopup("Transparency", selectedVoxel.VTransparency); // collision selectedVoxel.VColliderType = (ColliderType)EditorGUILayout.EnumPopup("Collider", selectedVoxel.VColliderType); GUILayout.Space(10); // components GUILayout.Label("Components"); foreach (Object component in SelectedBlock.GetComponents <Component>()) { if (component is Transform == false && component is Voxel == false) { GUILayout.Label(component.GetType().ToString()); } } GUILayout.Space(20); // apply if (GUILayout.Button("Apply", GUILayout.Height(80))) { if (SelectedPrefab != null && SelectedPrefab.GetComponent <Voxel>().GetID() != selectedVoxel.GetID() && // if id was changed GetBlock(selectedVoxel.GetID()) != null) // and there is already a block with this id { ReplaceBlockDialog = true; } else { ReplaceBlockDialog = false; UpdateBlock(); ApplyBlocks(); GetBlocks(); } } if (ReplaceBlockDialog) { GUILayout.Label("A block with this ID already exists!" + SelectedPrefab.GetComponent <Voxel>().GetID() + selectedVoxel.GetID()); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { resourceObject.Update(); GUI.enabled = AssetDatabase.IsOpenForEdit(this.target, StatusQueryOptions.UseCachedIfPossible); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = resourceUpdateModeProperty.hasMultipleDifferentValues; VFXUpdateMode newUpdateMode = (VFXUpdateMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TrTextContent("Update Mode", "Specifies whether particles are updated using a fixed timestep (Fixed Delta Time), or in a frame-rate independent manner (Delta Time)."), (VFXUpdateMode)resourceUpdateModeProperty.intValue); if (EditorGUI.EndChangeCheck()) { resourceUpdateModeProperty.intValue = (int)newUpdateMode; resourceObject.ApplyModifiedProperties(); } EditorGUILayout.BeginHorizontal(); EditorGUI.showMixedValue = cullingFlagsProperty.hasMultipleDifferentValues; EditorGUILayout.PrefixLabel(EditorGUIUtility.TrTextContent("Culling Flags", "Specifies how the system recomputes its bounds and simulates when off-screen.")); EditorGUI.BeginChangeCheck(); int newOption = EditorGUILayout.Popup(Array.IndexOf(k_CullingOptionsValue, (VFXCullingFlags)cullingFlagsProperty.intValue), k_CullingOptionsContents); if (EditorGUI.EndChangeCheck()) { cullingFlagsProperty.intValue = (int)k_CullingOptionsValue[newOption]; resourceObject.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); if (prewarmDeltaTime != null && prewarmStepCount != null) { if (!prewarmDeltaTime.hasMultipleDifferentValues && !prewarmStepCount.hasMultipleDifferentValues) { var currentDeltaTime = prewarmDeltaTime.floatValue; var currentStepCount = prewarmStepCount.intValue; var currentTotalTime = currentDeltaTime * currentStepCount; EditorGUI.BeginChangeCheck(); currentTotalTime = EditorGUILayout.FloatField(EditorGUIUtility.TrTextContent("PreWarm Total Time", "Sets the time in seconds to advance the current effect to when it is initially played. "), currentTotalTime); if (EditorGUI.EndChangeCheck()) { if (currentStepCount <= 0) { prewarmStepCount.intValue = currentStepCount = 1; } currentDeltaTime = currentTotalTime / currentStepCount; prewarmDeltaTime.floatValue = currentDeltaTime; resourceObject.ApplyModifiedProperties(); } EditorGUI.BeginChangeCheck(); currentStepCount = EditorGUILayout.IntField(EditorGUIUtility.TrTextContent("PreWarm Step Count", "Sets the number of simulation steps the prewarm should be broken down to. "), currentStepCount); if (EditorGUI.EndChangeCheck()) { if (currentStepCount <= 0 && currentTotalTime != 0.0f) { prewarmStepCount.intValue = currentStepCount = 1; } currentDeltaTime = currentTotalTime == 0.0f ? 0.0f : currentTotalTime / currentStepCount; prewarmDeltaTime.floatValue = currentDeltaTime; prewarmStepCount.intValue = currentStepCount; resourceObject.ApplyModifiedProperties(); } EditorGUI.BeginChangeCheck(); currentDeltaTime = EditorGUILayout.FloatField(EditorGUIUtility.TrTextContent("PreWarm Delta Time", "Sets the time in seconds for each step to achieve the desired total prewarm time."), currentDeltaTime); if (EditorGUI.EndChangeCheck()) { if (currentDeltaTime < k_MinimalCommonDeltaTime) { prewarmDeltaTime.floatValue = currentDeltaTime = k_MinimalCommonDeltaTime; } if (currentDeltaTime > currentTotalTime) { currentTotalTime = currentDeltaTime; } if (currentTotalTime != 0.0f) { var candidateStepCount_A = Mathf.FloorToInt(currentTotalTime / currentDeltaTime); var candidateStepCount_B = Mathf.RoundToInt(currentTotalTime / currentDeltaTime); var totalTime_A = currentDeltaTime * candidateStepCount_A; var totalTime_B = currentDeltaTime * candidateStepCount_B; if (Mathf.Abs(totalTime_A - currentTotalTime) < Mathf.Abs(totalTime_B - currentTotalTime)) { currentStepCount = candidateStepCount_A; } else { currentStepCount = candidateStepCount_B; } prewarmStepCount.intValue = currentStepCount; } prewarmDeltaTime.floatValue = currentDeltaTime; resourceObject.ApplyModifiedProperties(); } } else { //Multi selection case, can't resolve total time easily EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = prewarmStepCount.hasMultipleDifferentValues; EditorGUILayout.PropertyField(prewarmStepCount, EditorGUIUtility.TrTextContent("PreWarm Step Count", "Sets the number of simulation steps the prewarm should be broken down to.")); EditorGUI.showMixedValue = prewarmDeltaTime.hasMultipleDifferentValues; EditorGUILayout.PropertyField(prewarmDeltaTime, EditorGUIUtility.TrTextContent("PreWarm Delta Time", "Sets the time in seconds for each step to achieve the desired total prewarm time.")); if (EditorGUI.EndChangeCheck()) { if (prewarmDeltaTime.floatValue < k_MinimalCommonDeltaTime) { prewarmDeltaTime.floatValue = k_MinimalCommonDeltaTime; } resourceObject.ApplyModifiedProperties(); } } } if (initialEventName != null) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = initialEventName.hasMultipleDifferentValues; EditorGUILayout.PropertyField(initialEventName, new GUIContent("Initial Event Name", "Sets the name of the event which triggers once the system is activated. Default: ‘OnPlay’.")); if (EditorGUI.EndChangeCheck()) { resourceObject.ApplyModifiedProperties(); } } if (!serializedObject.isEditingMultipleObjects) { VisualEffectAsset asset = (VisualEffectAsset)target; VisualEffectResource resource = asset.GetResource(); m_OutputContexts.Clear(); m_OutputContexts.AddRange(resource.GetOrCreateGraph().children.OfType <IVFXSubRenderer>().OrderBy(t => t.sortPriority)); m_ReorderableList.DoLayoutList(); VisualEffectEditor.ShowHeader(EditorGUIUtility.TrTextContent("Shaders"), false, false); var shaderSources = VFXExternalShaderProcessor.allowExternalization ? resource.shaderSources : null; string assetPath = AssetDatabase.GetAssetPath(asset); UnityObject[] objects = AssetDatabase.LoadAllAssetsAtPath(assetPath); string directory = Path.GetDirectoryName(assetPath) + "/" + VFXExternalShaderProcessor.k_ShaderDirectory + "/" + asset.name + "/"; foreach (var shader in objects) { if (shader is Shader || shader is ComputeShader) { GUILayout.BeginHorizontal(); Rect r = GUILayoutUtility.GetRect(0, 18, GUILayout.ExpandWidth(true)); int buttonsWidth = VFXExternalShaderProcessor.allowExternalization ? 250 : 160; Rect labelR = r; labelR.width -= buttonsWidth; GUI.Label(labelR, shader.name); int index = resource.GetShaderIndex(shader); if (index >= 0) { if (VFXExternalShaderProcessor.allowExternalization && index < shaderSources.Length) { string externalPath = directory + shaderSources[index].name; if (!shaderSources[index].compute) { externalPath = directory + shaderSources[index].name.Replace('/', '_') + VFXExternalShaderProcessor.k_ShaderExt; } else { externalPath = directory + shaderSources[index].name + VFXExternalShaderProcessor.k_ShaderExt; } Rect buttonRect = r; buttonRect.xMin = labelR.xMax; buttonRect.width = 80; labelR.width += 80; if (System.IO.File.Exists(externalPath)) { if (GUI.Button(buttonRect, "Reveal External")) { EditorUtility.RevealInFinder(externalPath); } } else { if (GUI.Button(buttonRect, "Externalize")) { Directory.CreateDirectory(directory); File.WriteAllText(externalPath, "//" + shaderSources[index].name + "," + index.ToString() + "\n//Don't delete the previous line or this one\n" + shaderSources[index].source); } } } Rect buttonR = r; buttonR.xMin = labelR.xMax; buttonR.width = 110; labelR.width += 110; if (GUI.Button(buttonR, "Show Generated")) { resource.ShowGeneratedShaderFile(index); } } Rect selectButtonR = r; selectButtonR.xMin = labelR.xMax; selectButtonR.width = 50; if (GUI.Button(selectButtonR, "Select")) { Selection.activeObject = shader; } GUILayout.EndHorizontal(); } } } GUI.enabled = false; }
private void OnGitIgnoreRulesGUI() { var gitignoreRulesWith = Position.width - Styles.GitIgnoreRulesTotalHorizontalMargin - Styles.GitIgnoreRulesSelectorWidth - 16f; var effectWidth = gitignoreRulesWith * Styles.GitIgnoreRulesEffectRatio; var fileWidth = gitignoreRulesWith * Styles.GitIgnoreRulesFileRatio; var lineWidth = gitignoreRulesWith * Styles.GitIgnoreRulesLineRatio; GUILayout.Label(GitIgnoreRulesTitle, EditorStyles.boldLabel); GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(EditorStyles.toolbar); { GUILayout.Space(Styles.GitIgnoreRulesSelectorWidth); TableCell(GitIgnoreRulesEffect, effectWidth); TableCell(GitIgnoreRulesFile, fileWidth); TableCell(GitIgnoreRulesLine, lineWidth); } GUILayout.EndHorizontal(); var count = GitIgnoreRule.Count; for (var index = 0; index < count; ++index) { GitIgnoreRule rule; if (GitIgnoreRule.TryLoad(index, out rule)) { GUILayout.BeginHorizontal(); { GUILayout.Space(Styles.GitIgnoreRulesSelectorWidth); if (gitIgnoreRulesSelection == index && Event.current.type == EventType.Repaint) { var selectorRect = GUILayoutUtility.GetLastRect(); selectorRect.Set(selectorRect.x, selectorRect.y + 2f, selectorRect.width - 2f, EditorGUIUtility.singleLineHeight); EditorStyles.foldout.Draw(selectorRect, false, false, false, false); } TableCell(rule.Effect.ToString(), effectWidth); // TODO: Tint if the regex is null TableCell(rule.FileString, fileWidth); TableCell(rule.LineString, lineWidth); } GUILayout.EndHorizontal(); if (Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { newGitIgnoreRulesSelection = index; Event.current.Use(); } } } GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(NewGitIgnoreRuleButton, EditorStyles.miniButton)) { GitIgnoreRule.New(); GUIUtility.hotControl = GUIUtility.keyboardControl = -1; } } GUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); // Selected gitignore rule edit GitIgnoreRule selectedRule; if (GitIgnoreRule.TryLoad(gitIgnoreRulesSelection, out selectedRule)) { GUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(DeleteGitIgnoreRuleButton, EditorStyles.miniButton)) { GitIgnoreRule.Delete(gitIgnoreRulesSelection); newGitIgnoreRulesSelection = gitIgnoreRulesSelection - 1; } } GUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); var newEffect = (GitIgnoreRuleEffect)EditorGUILayout.EnumPopup(GitIgnoreRulesEffect, selectedRule.Effect); var newFile = EditorGUILayout.TextField(GitIgnoreRulesFile, selectedRule.FileString); var newLine = EditorGUILayout.TextField(GitIgnoreRulesLine, selectedRule.LineString); GUILayout.Label(GitIgnoreRulesDescription); var newDescription = EditorGUILayout.TextArea(selectedRule.TriggerText, Styles.CommitDescriptionFieldStyle); if (EditorGUI.EndChangeCheck()) { GitIgnoreRule.Save(gitIgnoreRulesSelection, newEffect, newFile, newLine, newDescription); // TODO: Fix this } } GUILayout.EndVertical(); } GUILayout.EndVertical(); }
private void ChannelTypeGui([NotNull] VoiceBroadcastTrigger transmitter) { transmitter.ChangeWithUndo( "Changed Dissonance Channel Type", (CommTriggerTarget)EditorGUILayout.EnumPopup(new GUIContent("Channel Type", "Where this trigger sends voice to"), transmitter.ChannelType), transmitter.ChannelType, a => transmitter.ChannelType = a ); if (transmitter.ChannelType == CommTriggerTarget.Player) { transmitter.ChangeWithUndo( "Changed Dissonance Channel Transmitter Player Name", EditorGUILayout.TextField(new GUIContent("Recipient Player Name", "The name of the player receiving voice from this trigger"), transmitter.PlayerId), transmitter.PlayerId, a => transmitter.PlayerId = a ); EditorGUILayout.HelpBox("Player mode sends voice data to the specified player.", MessageType.None); } if (transmitter.ChannelType == CommTriggerTarget.Room) { var roomNames = _roomSettings.Names; var haveRooms = roomNames.Count > 0; if (haveRooms) { EditorGUILayout.BeginHorizontal(); var selectedIndex = string.IsNullOrEmpty(transmitter.RoomName) ? -1 : roomNames.IndexOf(transmitter.RoomName); transmitter.ChangeWithUndo( "Changed Dissonance Transmitter Room", EditorGUILayout.Popup(new GUIContent("Chat Room", "The room to send voice to"), selectedIndex, roomNames.Select(a => new GUIContent(a)).ToArray()), selectedIndex, a => transmitter.RoomName = roomNames[a] ); if (GUILayout.Button("Config Rooms")) { ChatRoomSettingsEditor.GoToSettings(); } EditorGUILayout.EndHorizontal(); if (string.IsNullOrEmpty(transmitter.RoomName)) { EditorGUILayout.HelpBox("No chat room selected", MessageType.Error); } else if (!roomNames.Contains(transmitter.RoomName)) { EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", transmitter.RoomName), MessageType.Warning); } } else { if (GUILayout.Button("Create New Rooms")) { ChatRoomSettingsEditor.GoToSettings(); } } EditorGUILayout.HelpBox("Room mode sends voice data to all players in the specified room.", MessageType.None); if (!haveRooms) { EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning); } } if (transmitter.ChannelType == CommTriggerTarget.Self) { EditorGUILayout.HelpBox( "Self mode sends voice data to the DissonancePlayer attached to this game object.", MessageType.None ); var player = transmitter.GetComponent <IDissonancePlayer>(); if (player == null) { EditorGUILayout.HelpBox( "This entity has no Dissonance player component!", MessageType.Error ); } else if (Application.isPlaying && player.Type == NetworkPlayerType.Local) { EditorGUILayout.HelpBox( "This is the local player.\n" + "Are you sure you mean to broadcast to the local player?", MessageType.Warning ); } } }
void OnGUI() { if (null == mRipData) { return; } if (null == mStyles) { mStyles = new Styles(); } int vertexNum = (int)mRipData.vertexCount; float height = this.position.height - 20; float width = 40; int viewItemNum = Mathf.FloorToInt(height / 18 - 1); current = (int)GUI.VerticalScrollbar(new Rect(0, 0, 20, height + 3), current, viewItemNum, 0, vertexNum); int end = Mathf.Min(current + viewItemNum, vertexNum); int start = Mathf.Max(0, end - viewItemNum); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(20); //draw id EditorGUILayout.BeginVertical(mStyles.mPreviewBox, GUILayout.Width(width), GUILayout.Height(height)); { EditorGUILayout.BeginHorizontal(mStyles.mOLTitle); { EditorGUILayout.LabelField(" id", EditorStyles.boldLabel, GUILayout.Width(width)); } EditorGUILayout.EndHorizontal(); for (int i = start; i < end; ++i) { EditorGUILayout.LabelField(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(width)); } } EditorGUILayout.EndVertical(); GUILayout.Space(1); //data DataPanelScroll = EditorGUILayout.BeginScrollView(DataPanelScroll); EditorGUILayout.BeginHorizontal(); { for (int i = 0; i < mRipData.elements.Length; ++i) { RipAttributeElement ele = mRipData.elements[i]; width = ele.dimension * 100; EditorGUILayout.BeginVertical(mStyles.mPreviewBox, GUILayout.Width(width), GUILayout.Height(height)); { EditorGUILayout.BeginHorizontal(mStyles.mOLTitle); { ele.sematic = (ESemantic)EditorGUILayout.EnumPopup(ele.sematic, GUILayout.Width(width)); } EditorGUILayout.EndHorizontal(); for (int j = start; j < end; ++j) { EditorGUILayout.BeginHorizontal(); for (int k = 0; k < ele.dimension; ++k) { EditorGUILayout.LabelField(mRipData.vertexData[j * mRipData.dimensionPerVertex + k + ele.bytesOffset / 4].ToString(), GUILayout.Width(90)); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); } EditorGUILayout.BeginVertical(); { GUILayout.Label(mRipData.GetInfo()); mMdlscaler = EditorGUILayout.FloatField("Scale:", mMdlscaler); if (GUILayout.Button("确认导入")) { onMeshDataPrepared(ConvertRipToMeshData(mRipData)); this.Close(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
private void DrawBottomTools() { var buildObj = target as ConfigBuildObj; GUIStyle labStyle = EditorStyles.miniBoldLabel; GUILayoutOption labLayout = GUILayout.Width(100); using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[目标平台]:", labStyle, labLayout); buildObj.buildTarget = (BuildTarget)EditorGUILayout.EnumPopup(buildObj.buildTarget); } using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[打包选项]:", labStyle, labLayout); buildObj.buildOption = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField(buildObj.buildOption); } using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[清空文件]:", labStyle, labLayout); buildObj.clearOld = EditorGUILayout.Toggle(buildObj.clearOld); } using (var hor = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("生成AB(全部)", EditorStyles.toolbarDropDown)) { if (buildObj.clearOld) { FileUtil.DeleteFileOrDirectory(buildObj.LocalPath); } ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>(); StoreLayerNodeToAsset(nodeDic, bo); ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget); } if (GUILayout.Button("生成AB(选中)", EditorStyles.toolbarDropDown)) { if (buildObj.clearOld) { FileUtil.DeleteFileOrDirectory(buildObj.LocalPath); } ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>(); StoreLayerNodeToAsset(nodeDic, bo, true); ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget); } } using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[拷贝到路径]:", GUILayout.Width(100)); targetPath_prop.stringValue = EditorGUILayout.TextField(targetPath_prop.stringValue); if (GUILayout.Button("选择")) { var path = EditorUtility.OpenFolderPanel("选择文件路径", targetPath_prop.stringValue, ""); if (!string.IsNullOrEmpty(path)) { targetPath_prop.stringValue = path; } } if (GUILayout.Button("拷贝")) { if (buildObj.LocalPath != buildObj.TargetPath && !string.IsNullOrEmpty(buildObj.TargetPath)) { FileUtil.DeleteFileOrDirectory(buildObj.TargetPath); FileUtil.CopyFileOrDirectory(buildObj.LocalPath, buildObj.TargetPath); } } } }
public void DrawAnchorTransform() { if (NGUIEditorTools.DrawHeader("Anchors")) { NGUIEditorTools.BeginContents(); NGUIEditorTools.SetLabelWidth(NGUISettings.minimalisticLook ? 69f : 62f); EditorGUI.BeginDisabledGroup(!((target as UIRect).canBeAnchored)); GUILayout.BeginHorizontal(); AnchorType type = (AnchorType)EditorGUILayout.EnumPopup("Type", mAnchorType); NGUIEditorTools.DrawPadding(); GUILayout.EndHorizontal(); SerializedProperty[] tg = new SerializedProperty[4]; for (int i = 0; i < 4; ++i) { tg[i] = serializedObject.FindProperty(FieldName[i] + ".target"); } if (mAnchorType == AnchorType.None && type != AnchorType.None) { if (type == AnchorType.Unified) { if (mTarget[0] == null && mTarget[1] == null && mTarget[2] == null && mTarget[3] == null) { UIRect rect = target as UIRect; UIRect parent = NGUITools.FindInParents <UIRect>(rect.cachedTransform.parent); if (parent != null) { for (int i = 0; i < 4; ++i) { mTarget[i] = parent.cachedTransform; } } } } for (int i = 0; i < 4; ++i) { tg[i].objectReferenceValue = mTarget[i]; mTarget[i] = null; } UpdateAnchors(true); } if (type != AnchorType.None) { NGUIEditorTools.DrawPaddedProperty("Execute", serializedObject, "updateAnchors"); } if (type == AnchorType.Advanced) { DrawAnchor(0, true); DrawAnchor(1, true); DrawAnchor(2, true); DrawAnchor(3, true); } else if (type == AnchorType.Unified) { DrawSingleAnchorSelection(); DrawAnchor(0, false); DrawAnchor(1, false); DrawAnchor(2, false); DrawAnchor(3, false); } else if (type == AnchorType.None && mAnchorType != type) { // Save values to make it easy to "go back" for (int i = 0; i < 4; ++i) { mTarget[i] = tg[i].objectReferenceValue as Transform; tg[i].objectReferenceValue = null; } serializedObject.FindProperty("leftAnchor.relative").floatValue = 0f; serializedObject.FindProperty("bottomAnchor.relative").floatValue = 0f; serializedObject.FindProperty("rightAnchor.relative").floatValue = 1f; serializedObject.FindProperty("topAnchor.relative").floatValue = 1f; } mAnchorType = type; OnDrawFinalProperties(); EditorGUI.EndDisabledGroup(); NGUIEditorTools.EndContents(); } }
public override void OnInspectorGUI() { var targ = (InputDefaults)target; if (GUILayout.Button("+")) { targ.Inputs.Add(new Button() { Name = "New Button" }); } for (int i = 0; i < targ.Inputs.Count; i++) { if (visibleInputs.ElementAtOrDefault(i) == null) { visibleInputs.Add(false); } visibleInputs[i] = EditorGUILayout.Foldout(visibleInputs[i].Value, targ.Inputs[i].Name); if (visibleInputs[i].Value) { EditorGUI.indentLevel = 1; targ.Inputs[i].Name = EditorGUILayout.TextField("Input Name", targ.Inputs[i].Name); EditorGUILayout.LabelField("Main Input...", EditorStyles.boldLabel); targ.Inputs[i].MainInputType = (ButtonInputType)EditorGUILayout.EnumPopup("Main Input Type", targ.Inputs[i].MainInputType); if (targ.Inputs[i].MainInputType == ButtonInputType.Keys) { targ.Inputs[i].PositiveKey = (KeyCode)EditorGUILayout.EnumPopup("Positive/Main Key", targ.Inputs[i].PositiveKey); targ.Inputs[i].NegativeKey = (KeyCode)EditorGUILayout.EnumPopup("Negative Key", targ.Inputs[i].NegativeKey); } else { targ.Inputs[i].Axis = EditorGUILayout.TextField("Axis", targ.Inputs[i].Axis); targ.Inputs[i].ButtonDirection = (PositiveNegative)EditorGUILayout.EnumPopup("Axis Direction", targ.Inputs[i].ButtonDirection); } EditorGUILayout.LabelField("Alt Input...", EditorStyles.boldLabel); targ.Inputs[i].AlternativeInputType = (ButtonInputType)EditorGUILayout.EnumPopup("Alt Input Type", targ.Inputs[i].AlternativeInputType); if (targ.Inputs[i].AlternativeInputType == ButtonInputType.Keys) { targ.Inputs[i].AlternativePositiveKey = (KeyCode)EditorGUILayout.EnumPopup("Positive/Main Key", targ.Inputs[i].AlternativePositiveKey); targ.Inputs[i].AlternativeNegativeKey = (KeyCode)EditorGUILayout.EnumPopup("Negative Key", targ.Inputs[i].AlternativeNegativeKey); } else { targ.Inputs[i].AlternativeAxis = EditorGUILayout.TextField("Axis", targ.Inputs[i].AlternativeAxis); targ.Inputs[i].AlternativeButtonDirection = (PositiveNegative)EditorGUILayout.EnumPopup("Axis Direction", targ.Inputs[i].AlternativeButtonDirection); } if (GUILayout.Button("-")) { targ.Inputs.RemoveAt(i); visibleInputs.RemoveAt(i); } EditorGUI.indentLevel = 0; } } if (GUI.changed) { EditorUtility.SetDirty(targ); } }
private void DrawDebugSection() { if (InspectorUIUtility.DrawSectionFoldoutWithKey("Debug Options", ShowDebugOptionsPrefKey, MixedRealityStylesUtility.BoldFoldoutStyle)) { using (new EditorGUI.IndentLevelScope()) { using (var check = new EditorGUI.ChangeCheckScope()) { EditorGUILayout.PropertyField(maskEnabled); if (check.changed) { scrollView.MaskEnabled = maskEnabled.boolValue; EditorUtility.SetDirty(target); } } using (new EditorGUI.DisabledGroupScope(EditorApplication.isPlaying)) { visibleDebugPlanes = EditorGUILayout.Toggle("Show Threshold Planes", visibleDebugPlanes); EditorGUILayout.Space(); } } using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlaying)) { if (ShowDebugPagination = EditorGUILayout.Foldout(ShowDebugPagination, new GUIContent("Debug Pagination", "Pagination is only available during playmode."), MixedRealityStylesUtility.BoldFoldoutStyle)) { using (new EditorGUI.IndentLevelScope()) { animateTransition = EditorGUILayout.Toggle(new GUIContent("Animate", "Toggling will use animation to move scroller to new position."), animateTransition); using (new EditorGUILayout.HorizontalScope()) { debugPaginationMode = (PaginationMode)EditorGUILayout.EnumPopup(new GUIContent("Pagination Mode"), debugPaginationMode, GUILayout.Width(400.0f)); paginationMoveNumber = EditorGUILayout.IntField(paginationMoveNumber); if (GUILayout.Button("Move")) { switch (debugPaginationMode) { case PaginationMode.ByTier: default: scrollView.MoveByTiers(paginationMoveNumber, animateTransition); break; case PaginationMode.ByPage: scrollView.MoveByPages(paginationMoveNumber, animateTransition); break; case PaginationMode.ToCellIndex: scrollView.MoveToIndex(paginationMoveNumber, animateTransition); break; } } } } } } } } }
public override void OnInspectorGUI() { //MAIN LAYOUT scrollPos = EditorGUILayout.BeginScrollView(scrollPos); EditorGUILayout.BeginVertical(rootGroupStyle); EditorGUILayout.BeginHorizontal(rootGroupStyle); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("GAME CONFIGURATION", EditorStyles.boldLabel); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //MUSIC. EditorGUILayout.BeginVertical(rootGroupStyle); instance.showMusic = EditorGUILayout.Foldout(instance.showMusic, ("MUSIC"), EditorStyles.foldout); if (instance.showMusic) { EditorGUILayout.BeginVertical(rootGroupStyle); instance.MUSIC.gameMusic = (AudioClip)EditorGUILayout.ObjectField("Game Music:", instance.MUSIC.gameMusic, (typeof(AudioClip)), false); instance.MUSIC.looseMusic = (AudioClip)EditorGUILayout.ObjectField("Loose Music:", instance.MUSIC.looseMusic, (typeof(AudioClip)), false); instance.MUSIC.countDownSound = (AudioClip)EditorGUILayout.ObjectField("Countdown Sound:", instance.MUSIC.countDownSound, (typeof(AudioClip)), false); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //END MUSIC. //GUI. EditorGUILayout.BeginVertical(rootGroupStyle); instance.showGui = EditorGUILayout.Foldout(instance.showGui, ("GUI"), EditorStyles.foldout); if (instance.showGui) { EditorGUILayout.BeginVertical(rootGroupStyle); //Config instance.GUI.gameoverDelay = EditorGUILayout.FloatField("Game Over Delay:", instance.GUI.gameoverDelay); instance.GUI.gamesPerAds = EditorGUILayout.IntField("Show Ads every:", instance.GUI.gamesPerAds); instance.GUI.gamesPerRate = EditorGUILayout.IntField("Show Rate every:", instance.GUI.gamesPerRate); //Menus instance.GUI.gameoverMenu = (GameOverMenu)EditorGUILayout.ObjectField("Game Over Menu:", instance.GUI.gameoverMenu, (typeof(GameOverMenu)), false); instance.GUI.pauseMenu = (PauseMenu)EditorGUILayout.ObjectField("Pause Menu:", instance.GUI.pauseMenu, (typeof(PauseMenu)), false); instance.GUI.objectivesMenu = (Objectives)EditorGUILayout.ObjectField("Objectives Menu:", instance.GUI.objectivesMenu, (typeof(Objectives)), false); instance.GUI.storeMenu = (StoreMenu)EditorGUILayout.ObjectField("Store Menu:", instance.GUI.storeMenu, (typeof(StoreMenu)), false); instance.GUI.optionsMenu = (Options)EditorGUILayout.ObjectField("Options Menu:", instance.GUI.optionsMenu, (typeof(Options)), false); instance.GUI.scoresMenu = (ChoosScore)EditorGUILayout.ObjectField("Scores Menu:", instance.GUI.scoresMenu, (typeof(ChoosScore)), false); instance.GUI.rateMenu = (RateApp)EditorGUILayout.ObjectField("Scores Menu:", instance.GUI.rateMenu, (typeof(RateApp)), false); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //END GUI. //STORE. EditorGUILayout.BeginVertical(rootGroupStyle); instance.showStore = EditorGUILayout.Foldout(instance.showStore, ("STORE ITEMS"), EditorStyles.foldout); if (instance.showStore) { EditorGUILayout.Space(); //SUITS EditorGUILayout.BeginHorizontal(subGroupStyle); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("SUITS"); GUILayout.FlexibleSpace(); if (StyledButton("ADD SUIT")) { addSuit(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (instance.STORE_ITEMS.suits.Count == 0) { EditorGUILayout.BeginVertical(subGroupStyle); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("NO SUITS YET"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.BeginVertical(rootGroupStyle); for (int s = 0; s < instance.STORE_ITEMS.suits.Count; s++) { EditorGUILayout.BeginVertical(rootGroupStyle); instance.STORE_ITEMS.suits[s].showItem = EditorGUILayout.Foldout(instance.STORE_ITEMS.suits[s].showItem, (System.String.IsNullOrEmpty(instance.STORE_ITEMS.suits[s].name)? "NEW SUIT":instance.STORE_ITEMS.suits[s].name.ToUpper()), EditorStyles.foldout); if (instance.STORE_ITEMS.suits[s].showItem) { instance.STORE_ITEMS.suits[s].name = EditorGUILayout.TextField("Name:", instance.STORE_ITEMS.suits[s].name); instance.STORE_ITEMS.suits[s].itemId = EditorGUILayout.TextField("Item ID:", instance.STORE_ITEMS.suits[s].itemId); instance.STORE_ITEMS.suits[s].cost = EditorGUILayout.IntField("Cost:", instance.STORE_ITEMS.suits[s].cost); instance.STORE_ITEMS.suits[s].type = (Item.ItemType)EditorGUILayout.EnumPopup("Type:", instance.STORE_ITEMS.suits[s].type); instance.STORE_ITEMS.suits[s].icon = (Sprite)EditorGUILayout.ObjectField("Icon:", instance.STORE_ITEMS.suits[s].icon, typeof(Sprite), false); instance.STORE_ITEMS.suits[s].texture = (Texture)EditorGUILayout.ObjectField("Texture:", instance.STORE_ITEMS.suits[s].texture, typeof(Texture), false); EditorGUILayout.BeginHorizontal(); if (StyledButton("Remove")) { removeSuit(s); } if (StyledButton("Move Up")) { moveUpSuit(s); } if (StyledButton("Move Down")) { moveDownSuit(s); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); //END SUITS. } EditorGUILayout.Space(); //BOARDS. EditorGUILayout.BeginHorizontal(subGroupStyle); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("BOARDS"); GUILayout.FlexibleSpace(); if (StyledButton("ADD BOARD")) { addBoard(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (instance.STORE_ITEMS.boards.Count == 0) { EditorGUILayout.BeginVertical(subGroupStyle); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("NO BOARDS YET"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.BeginVertical(rootGroupStyle); for (int s = 0; s < instance.STORE_ITEMS.boards.Count; s++) { EditorGUILayout.BeginVertical(rootGroupStyle); instance.STORE_ITEMS.boards[s].showItem = EditorGUILayout.Foldout(instance.STORE_ITEMS.boards[s].showItem, (System.String.IsNullOrEmpty(instance.STORE_ITEMS.boards[s].name)? "NEW BOARD":instance.STORE_ITEMS.boards[s].name.ToUpper()), EditorStyles.foldout); if (instance.STORE_ITEMS.boards[s].showItem) { instance.STORE_ITEMS.boards[s].name = EditorGUILayout.TextField("Name:", instance.STORE_ITEMS.boards[s].name); instance.STORE_ITEMS.boards[s].itemId = EditorGUILayout.TextField("Item ID:", instance.STORE_ITEMS.boards[s].itemId); instance.STORE_ITEMS.boards[s].cost = EditorGUILayout.IntField("Cost:", instance.STORE_ITEMS.boards[s].cost); instance.STORE_ITEMS.boards[s].type = (Item.ItemType)EditorGUILayout.EnumPopup("Type:", instance.STORE_ITEMS.boards[s].type); instance.STORE_ITEMS.boards[s].icon = (Sprite)EditorGUILayout.ObjectField("Icon:", instance.STORE_ITEMS.boards[s].icon, typeof(Sprite), false); instance.STORE_ITEMS.boards[s].texture = (Texture)EditorGUILayout.ObjectField("Texture:", instance.STORE_ITEMS.boards[s].texture, typeof(Texture), false); EditorGUILayout.BeginHorizontal(); if (StyledButton("Remove")) { removeBoard(s); } if (StyledButton("Move Up")) { moveUpBoard(s); } if (StyledButton("Move Down")) { moveDownBoard(s); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); //END BOARDS. } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //END STORE. //EFFECTS. EditorGUILayout.BeginVertical(rootGroupStyle); instance.showMisc = EditorGUILayout.Foldout(instance.showMisc, ("EXTRA"), EditorStyles.foldout); if (instance.showMisc) { EditorGUILayout.BeginVertical(rootGroupStyle); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(rootGroupStyle); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("HIT EFFECTS"); GUILayout.FlexibleSpace(); if (StyledButton("ADD EFFECT")) { addEffect(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (instance.hitEffects.Length == 0) { EditorGUILayout.BeginVertical(rootGroupStyle); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("FILE EMPTY"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); } else { for (int e = 0; e < instance.hitEffects.Length; e++) { EditorGUILayout.BeginVertical(rootGroupStyle); EditorGUILayout.BeginHorizontal(); instance.hitEffects[e] = (Sprite)EditorGUILayout.ObjectField(instance.hitEffects[e], typeof(Sprite), false); if (StyledButton("Remove Effect")) { removeEffect(e); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //END EFFECTS. EditorGUILayout.BeginHorizontal(rootGroupStyle); EditorGUILayout.LabelField("CONNECTIONS", EditorStyles.boldLabel); instance.CONNECTIONS = (ConnectionsConfig)EditorGUILayout.ObjectField(instance.CONNECTIONS, (typeof(ConnectionsConfig)), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //END MAIN LAYOUT EditorUtility.SetDirty(instance); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { var importer = serializedObject.targetObject as AseFileImporter; var textureSettings = "textureSettings."; var importTypeProperty = serializedObject.FindProperty("importType"); EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel); { EditorGUI.indentLevel++; var importType = importTypeProperty.intValue; EditorGUI.BeginChangeCheck(); importType = EditorGUILayout.Popup("Import Type", importType, importTypes); if (EditorGUI.EndChangeCheck()) { importTypeProperty.intValue = importType; } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "pixelsPerUnit")); var meshTypeProperty = serializedObject.FindProperty(textureSettings + "meshType"); var meshType = (SpriteMeshType)meshTypeProperty.intValue; EditorGUI.BeginChangeCheck(); meshType = (SpriteMeshType)EditorGUILayout.EnumPopup("Mesh Type", meshType); if (EditorGUI.EndChangeCheck()) { meshTypeProperty.intValue = (int)meshType; } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "extrudeEdges")); if (importTypeProperty.intValue == (int)AseFileImportType.Sprite) { PivotPopup("Pivot"); } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "generatePhysics")); EditorGUILayout.Space(); importer.textureSettings.wrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup("Wrap Mode", importer.textureSettings.wrapMode); importer.textureSettings.filterMode = (FilterMode)EditorGUILayout.EnumPopup("Filter Mode", importer.textureSettings.filterMode); EditorGUI.indentLevel--; } EditorGUILayout.Space(); if (importer.animationSettings.Length > 0) { EditorGUILayout.LabelField("Animation Options", EditorStyles.boldLabel); { if (importer.animationSettings != null) { foreach (var animationSetting in importer.animationSettings) { DrawAnimationSetting(importer, animationSetting); } } } } if (importTypeProperty.intValue == (int)AseFileImportType.Tileset) { EditorGUILayout.LabelField("Tileset Options", EditorStyles.boldLabel); { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tileSize")); EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tilePadding")); EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tileOffset")); PivotPopup("Tile Pivot"); EditorGUI.indentLevel--; } } base.ApplyRevertGUI(); }
public override void OnInspectorGUI() { InitializeInspector(); if (spriteCollectionIndex == null || allSpriteCollectionNames == null) { GUILayout.Label("data not found"); if (GUILayout.Button("Refresh")) { initialized = false; InitializeInspector(); } return; } tk2dSpriteAnimation anim = (tk2dSpriteAnimation)target; EditorGUI.indentLevel++; EditorGUILayout.BeginVertical(); if (anim.clips.Length == 0) { if (GUILayout.Button("Add clip")) { anim.clips = new tk2dSpriteAnimationClip[1]; anim.clips[0] = new tk2dSpriteAnimationClip(); anim.clips[0].name = "New Clip 0"; anim.clips[0].frames = new tk2dSpriteAnimationFrame[1]; anim.clips[0].frames[0] = new tk2dSpriteAnimationFrame(); var spriteCollection = tk2dSpriteGuiUtility.GetDefaultSpriteCollection(); anim.clips[0].frames[0].spriteCollection = spriteCollection; anim.clips[0].frames[0].spriteId = spriteCollection.FirstValidDefinitionIndex; } } else // has anim clips { // All clips string[] allClipNames = new string[anim.clips.Length]; for (int i = 0; i < anim.clips.Length; ++i) { allClipNames[i] = anim.clips[i].name; } currentClip = Mathf.Clamp(currentClip, 0, anim.clips.Length); #region AddAndDeleteClipButtons EditorGUILayout.BeginHorizontal(); currentClip = EditorGUILayout.Popup("Clips", currentClip, allClipNames); // Add new clip if (GUILayout.Button("+", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14))) { int previousClipId = currentClip; // try to find an empty slot currentClip = -1; for (int i = 0; i < anim.clips.Length; ++i) { if (anim.clips[i].name.Length == 0) { currentClip = i; break; } } if (currentClip == -1) { tk2dSpriteAnimationClip[] clips = new tk2dSpriteAnimationClip[anim.clips.Length + 1]; for (int i = 0; i < anim.clips.Length; ++i) { clips[i] = anim.clips[i]; } currentClip = anim.clips.Length; clips[currentClip] = new tk2dSpriteAnimationClip(); anim.clips = clips; } string uniqueName = "New Clip "; int uniqueId = 0; for (int i = 0; i < anim.clips.Length; ++i) { string uname = uniqueName + uniqueId.ToString(); if (anim.clips[i].name == uname) { uniqueId++; i = -1; continue; } } anim.clips[currentClip] = new tk2dSpriteAnimationClip(); anim.clips[currentClip].name = uniqueName + uniqueId.ToString(); anim.clips[currentClip].fps = 15; anim.clips[currentClip].wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop; anim.clips[currentClip].frames = new tk2dSpriteAnimationFrame[1]; tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame(); if (previousClipId < anim.clips.Length && anim.clips[previousClipId] != null && anim.clips[previousClipId].frames != null && anim.clips[previousClipId].frames.Length != 0 && anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1] != null && anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1].spriteCollection != null) { var previousClip = anim.clips[previousClipId]; var lastFrame = previousClip.frames[previousClip.frames.Length - 1]; frame.spriteCollection = lastFrame.spriteCollection; frame.spriteId = lastFrame.spriteId; } else { var spriteCollection = tk2dSpriteGuiUtility.GetDefaultSpriteCollection(); frame.spriteCollection = spriteCollection; frame.spriteId = spriteCollection.FirstValidDefinitionIndex; } anim.clips[currentClip].frames[0] = frame; GUI.changed = true; } // Delete clip if (GUILayout.Button("-", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14))) { anim.clips[currentClip].name = ""; anim.clips[currentClip].frames = new tk2dSpriteAnimationFrame[0]; currentClip = 0; // find first non zero clip for (int i = 0; i < anim.clips.Length; ++i) { if (anim.clips[i].name != "") { currentClip = i; break; } } GUI.changed = true; } EditorGUILayout.EndHorizontal(); #endregion #region PruneClipList // Prune clip list int lastActiveClip = 0; for (int i = 0; i < anim.clips.Length; ++i) { if (!(anim.clips[i].name == "" && anim.clips[i].frames != null && anim.clips[i].frames.Length == 0)) { lastActiveClip = i; } } if (lastActiveClip != anim.clips.Length - 1) { System.Array.Resize <tk2dSpriteAnimationClip>(ref anim.clips, lastActiveClip + 1); GUI.changed = true; } #endregion // If anything has changed up to now, redraw if (GUI.changed) { EditorUtility.SetDirty(anim); Repaint(); return; } EditorGUI.indentLevel = 2; tk2dSpriteAnimationClip clip = anim.clips[currentClip]; // Clip properties // Name clip.name = EditorGUILayout.TextField("Name", clip.name); #region NumberOfFrames // Number of frames int clipNumFrames = (clip.frames != null)?clip.frames.Length:0; int newFrameCount = 0; if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Single) { newFrameCount = 1; // only one frame, no need to display } else { int maxFrameCount = 400; int startSection = Mathf.Max(clipNumFrames - 5, 1); int endSection = Mathf.Min(clipNumFrames + 5, maxFrameCount); string[] numFrameStr = new string[maxFrameCount - 1]; int div = 20; int divStart = 0; int divEnd = 0; string section = ""; for (int i = 1; i < startSection; ++i) { if (i > divEnd) { divStart = divEnd + 1; divEnd = Mathf.Min(startSection - 1, divStart + div - 1); section = divStart.ToString() + " .. " + divEnd.ToString(); } numFrameStr[i - 1] = section + "/" + i.ToString(); } for (int i = startSection; i < endSection; ++i) { numFrameStr[i - 1] = i.ToString(); } divEnd = endSection - 1; for (int i = endSection; i < maxFrameCount; ++i) { if (i > divEnd) { divStart = Mathf.Max(divEnd + 1, endSection); divEnd = Mathf.Min(((divStart + div) / div) * div, maxFrameCount - 1); section = divStart.ToString() + " .. " + divEnd.ToString(); } numFrameStr[i - 1] = section + "/" + i.ToString(); } newFrameCount = EditorGUILayout.Popup("Num Frames", clipNumFrames - 1, numFrameStr) + 1; if (newFrameCount == 0) { newFrameCount = 1; // minimum = 1 } } if (newFrameCount != clipNumFrames) { // Ungroup if (newFrameCount > clipNumFrames) { tk2dPreferences.inst.groupAnimDisplay = false; scrollPosition.y += 1000000.0f; // push to the end } tk2dSpriteAnimationFrame[] frames = new tk2dSpriteAnimationFrame[newFrameCount]; int c1 = Mathf.Min(clipNumFrames, frames.Length); for (int i = 0; i < c1; ++i) { frames[i] = new tk2dSpriteAnimationFrame(); frames[i].CopyFrom(clip.frames[i]); } if (c1 > 0) { for (int i = c1; i < frames.Length; ++i) { frames[i] = new tk2dSpriteAnimationFrame(); frames[i].CopyFrom(clip.frames[c1 - 1]); } } else { for (int i = 0; i < frames.Length; ++i) { frames[i] = new tk2dSpriteAnimationFrame(); var spriteCollection = tk2dSpriteGuiUtility.GetDefaultSpriteCollection(); frames[i].spriteCollection = spriteCollection; frames[i].spriteId = spriteCollection.FirstValidDefinitionIndex; } } clip.frames = frames; clipNumFrames = newFrameCount; } #endregion // Frame rate if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single) { clip.fps = EditorGUILayout.FloatField("Frame rate", clip.fps); } // Wrap mode clip.wrapMode = (tk2dSpriteAnimationClip.WrapMode)EditorGUILayout.EnumPopup("Wrap mode", clip.wrapMode); if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection) { clip.loopStart = EditorGUILayout.IntField("Loop start", clip.loopStart); clip.loopStart = Mathf.Clamp(clip.loopStart, 0, clip.frames.Length - 1); } #region DrawFrames EditorGUI.indentLevel = 0; GUILayout.Space(8); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.Label("Frames"); GUILayout.FlexibleSpace(); // Reverse if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single && GUILayout.Button("Reverse", EditorStyles.toolbarButton)) { System.Array.Reverse(clip.frames); GUI.changed = true; } // Auto fill if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single && clip.frames.Length >= 1) { AutoFill(clip); } if (GUILayout.Button(tk2dPreferences.inst.horizontalAnimDisplay?"H":"V", EditorStyles.toolbarButton, GUILayout.MaxWidth(24))) { tk2dPreferences.inst.horizontalAnimDisplay = !tk2dPreferences.inst.horizontalAnimDisplay; Repaint(); } tk2dPreferences.inst.groupAnimDisplay = GUILayout.Toggle(tk2dPreferences.inst.groupAnimDisplay, "Group", EditorStyles.toolbarButton); EditorGUILayout.EndHorizontal(); // Sanitize frame data for (int i = 0; i < clip.frames.Length; ++i) { if (clip.frames[i].spriteCollection == null || clip.frames[i].spriteCollection.spriteDefinitions.Length == 0) { EditorUtility.DisplayDialog("Warning", "Invalid sprite collection found.\nThis clip will now be deleted", "Ok"); clip.name = ""; clip.frames = new tk2dSpriteAnimationFrame[0]; Repaint(); return; } if (clip.frames[i].spriteId < 0 || clip.frames[i].spriteId >= clip.frames[i].spriteCollection.Count) { EditorUtility.DisplayDialog("Warning", "Invalid frame found, resetting to frame 0", "Ok"); clip.frames[i].spriteId = 0; } } // Warning when one of the frames has different poly count if (clipNumFrames > 0) { bool differentPolyCount = false; int polyCount = clip.frames[0].spriteCollection.spriteDefinitions[clip.frames[0].spriteId].positions.Length; for (int i = 1; i < clipNumFrames; ++i) { int thisPolyCount = clip.frames[i].spriteCollection.spriteDefinitions[clip.frames[i].spriteId].positions.Length; if (thisPolyCount != polyCount) { differentPolyCount = true; break; } } if (differentPolyCount) { Color bg = GUI.backgroundColor; GUI.backgroundColor = Color.red; GUILayout.TextArea("Sprites have different poly counts. Performance will be affected"); GUI.backgroundColor = bg; } } // Draw frames EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); DrawClipEditor(clip); EditorGUILayout.EndHorizontal(); #endregion } EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; if (GUI.changed) { EditorUtility.SetDirty(anim); } }
public override void OnInspectorGUI() { tk2dSlicedSprite sprite = (tk2dSlicedSprite)target; base.OnInspectorGUI(); if (sprite.Collection == null) { return; } EditorGUILayout.BeginVertical(); var spriteData = sprite.GetCurrentSpriteDef(); // need raw extents (excluding scale) Vector3 extents = spriteData.boundsData[1]; // this is the size of one texel Vector3 spritePixelMultiplier = new Vector3(0, 0); bool newCreateBoxCollider = EditorGUILayout.Toggle("Create Box Collider", sprite.CreateBoxCollider); if (newCreateBoxCollider != sprite.CreateBoxCollider) { Undo.RegisterUndo(targetSlicedSprites, "Create Box Collider"); sprite.CreateBoxCollider = newCreateBoxCollider; } // if either of these are zero, the division to rescale to pixels will result in a // div0, so display the data in fractions to avoid this situation bool editBorderInFractions = true; if (spriteData.texelSize.x != 0.0f && spriteData.texelSize.y != 0.0f && extents.x != 0.0f && extents.y != 0.0f) { spritePixelMultiplier = new Vector3(extents.x / spriteData.texelSize.x, extents.y / spriteData.texelSize.y, 1); editBorderInFractions = false; } if (!editBorderInFractions) { if (sprite.transform.localScale == Vector3.one && sprite.legacyMode) { Vector2 scalePixelUnits = new Vector2(spritePixelMultiplier.x * sprite.scale.x, spritePixelMultiplier.y * sprite.scale.y); Vector2 scalePixelUnitsChanged = EditorGUILayout.Vector2Field("Scale (Pixel Units)", scalePixelUnits); if (scalePixelUnits != scalePixelUnitsChanged) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite Scale"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.scale = new Vector3(scalePixelUnitsChanged.x / spritePixelMultiplier.x, scalePixelUnitsChanged.y / spritePixelMultiplier.y, sprite.scale.z); } } } else { Vector2 newDimensions = EditorGUILayout.Vector2Field("Dimensions (Pixel Units)", sprite.dimensions); if (newDimensions != sprite.dimensions) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite Dimensions"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.dimensions = newDimensions; } } tk2dSlicedSprite.Anchor newAnchor = (tk2dSlicedSprite.Anchor)EditorGUILayout.EnumPopup("Anchor", sprite.anchor); if (newAnchor != sprite.anchor) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite Anchor"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.anchor = newAnchor; } } } EditorGUILayout.PrefixLabel("Border"); EditorGUI.indentLevel++; float newBorderLeft = EditorGUILayout.FloatField("Left", sprite.borderLeft * spritePixelMultiplier.x) / spritePixelMultiplier.x; if (newBorderLeft != sprite.borderLeft) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderLeft"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderLeft = newBorderLeft; } } float newBorderRight = EditorGUILayout.FloatField("Right", sprite.borderRight * spritePixelMultiplier.x) / spritePixelMultiplier.x; if (newBorderRight != sprite.borderRight) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderRight"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderRight = newBorderRight; } } float newBorderTop = EditorGUILayout.FloatField("Top", sprite.borderTop * spritePixelMultiplier.y) / spritePixelMultiplier.y; if (newBorderTop != sprite.borderTop) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderTop"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderTop = newBorderTop; } } float newBorderBottom = EditorGUILayout.FloatField("Bottom", sprite.borderBottom * spritePixelMultiplier.y) / spritePixelMultiplier.y; if (newBorderBottom != sprite.borderBottom) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderBottom"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderBottom = newBorderBottom; } } bool newBorderOnly = EditorGUILayout.Toggle("Draw Border Only", sprite.BorderOnly); if (newBorderOnly != sprite.BorderOnly) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite Border Only"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.BorderOnly = newBorderOnly; } } EditorGUI.indentLevel--; } else { GUILayout.Label("Border (Displayed as Fraction).\nSprite Collection needs to be rebuilt.", "textarea"); EditorGUI.indentLevel++; float newBorderLeft = EditorGUILayout.FloatField("Left", sprite.borderLeft); if (newBorderLeft != sprite.borderLeft) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderLeft"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderLeft = newBorderLeft; } } float newBorderRight = EditorGUILayout.FloatField("Right", sprite.borderRight); if (newBorderRight != sprite.borderRight) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderRight"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderRight = newBorderRight; } } float newBorderTop = EditorGUILayout.FloatField("Top", sprite.borderTop); if (newBorderTop != sprite.borderTop) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderTop"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderTop = newBorderTop; } } float newBorderBottom = EditorGUILayout.FloatField("Bottom", sprite.borderBottom); if (newBorderBottom != sprite.borderBottom) { Undo.RegisterUndo(targetSlicedSprites, "Sliced Sprite BorderBottom"); foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.borderBottom = newBorderBottom; } } EditorGUI.indentLevel--; } // One of the border valus has changed, so simply rebuild mesh data here if (GUI.changed) { foreach (tk2dSlicedSprite spr in targetSlicedSprites) { spr.Build(); EditorUtility.SetDirty(spr); } } EditorGUILayout.EndVertical(); }
protected virtual void DrawFields() { UIGrid grid = target as UIGrid; int constraint = EditorGUILayout.IntField("Constraint", grid.constraint); Vector2 padding = EditorGUILayout.Vector2Field("Padding", grid.padding); Vector2 space = EditorGUILayout.Vector2Field("Space", grid.space); Vector2 cellSize = EditorGUILayout.Vector2Field("CellSize", grid.cellSize); LayoutCorner alignement = (LayoutCorner)EditorGUILayout.EnumPopup("Alignement", grid.alignement); SizeFitterType fitterType = (SizeFitterType)EditorGUILayout.EnumPopup("SizeFitter", grid.fitterType); bool fixedCellSize = EditorGUILayout.Toggle("FixedCellSize", grid.fixedCellSize); GUILayout.BeginHorizontal(); string prefabUIName = EditorGUILayout.TextField("Prefab UI", grid.prefabUI, GUILayout.Height(20)); if (m_PrefabUI == null || m_PrefabUI.name != prefabUIName) { m_PrefabUI = GetTargetUIPrefab(prefabUIName); } Rect rectbox = GUILayoutUtility.GetRect(16, 16, GUI.skin.box); if (m_PrefabUI != null) { GUI.Box(rectbox, EditorGUIUtility.IconContent("lightMeter/greenLight")); EditorTools.ClickAndPingObject(rectbox, m_PrefabUI); GUI.backgroundColor = Color.blue; if (GUILayout.Button("G", GUILayout.Width(18), GUILayout.Height(18))) { var temp = AssetDatabase.LoadAssetAtPath <GameObject>(string.Format("Assets/AssetBases/PrefabAssets/ui/{0}.prefab", prefabUIName)); if (temp != null) { var item = Object.Instantiate(temp); item.name = temp.name; item.transform.parent = grid.transform; item.transform.localScale = Vector3.one; } } GUI.backgroundColor = Color.red; if (GUILayout.Button("C", GUILayout.Width(18), GUILayout.Height(18))) { EditorTools.DestroyChild(grid.gameObject); } GUI.backgroundColor = Color.white; } GUILayout.EndHorizontal(); if (GUI.changed) { EditorTools.RegisterUndo("UIGrid", grid); grid.prefabUI = prefabUIName; grid.constraint = constraint; grid.padding = padding; grid.space = space; grid.cellSize = cellSize; grid.alignement = alignement; grid.fixedCellSize = fixedCellSize; grid.fitterType = fitterType; EditorTools.SetDirty(grid); } }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } newSetupMethod = (MadLevelGridLayout.SetupMethod)EditorGUILayout.EnumPopup("Setup Method", script.setupMethod); if (newSetupMethod != script.setupMethod) { if (newSetupMethod == MadLevelGridLayout.SetupMethod.Generate && EditorUtility.DisplayDialog( "Are you sure?", "Are you sure that you want to switch to Generate setup method? If you've made any changes to grid " + "object, these changes will be lost!", "Set to Generate", "Cancel")) { script.setupMethod = newSetupMethod; script.deepClean = true; EditorUtility.SetDirty(script); } else if (EditorUtility.DisplayDialog( "Are you sure?", "Are you sure that you want to switch to Manual setup method? Be aware that after doing this:\n" + "- You won't be able to change your level group (currently " + script.currentConfiguration.FindGroupById(script.configurationGroup).name + ")\n" + "- You won't be able to regenerate grid without losing custom changes", "Set to Manual", "Cancel")) { script.setupMethod = newSetupMethod; EditorUtility.SetDirty(script); } } serializedObject.UpdateIfDirtyOrScript(); if (script.setupMethod == MadLevelGridLayout.SetupMethod.Generate) { RebuildButton(); } GUILayout.Label("Fundaments", "HeaderLabel"); MadGUI.Indent(() => { ConfigurationField(); if (script.currentConfiguration != null) { var group = script.currentConfiguration.FindGroupById(script.configurationGroup); int index = GroupToIndex(script.currentConfiguration, group); var names = GroupNames(script.currentConfiguration); GUI.enabled = script.setupMethod == MadLevelGridLayout.SetupMethod.Generate; EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup("Group", index, names); if (EditorGUI.EndChangeCheck()) { script.configurationGroup = IndexToGroup(script.currentConfiguration, index).id; Rebuild(); } GUI.enabled = true; } EditorGUILayout.Space(); GUI.enabled = generate; MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet); if (script.iconTemplate != null) { var prefabType = PrefabUtility.GetPrefabType(script.iconTemplate); if (prefabType == PrefabType.None) { MadGUI.Warning("It's recommended to use prefab as a template. All visible icon instances will be linked to this prefab."); } } using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(enumerationType, "Enumeration"); using (MadGUI.Indent()) { MadGUI.PropertyField(enumerationOffset, "Offset"); } MadGUI.PropertyFieldVector2(iconScale, "Scale"); MadGUI.PropertyFieldVector2(iconOffset, "Offset"); } EditorGUILayout.Space(); GUI.enabled = true; MadGUI.PropertyField(leftSlideSprite, "Prev Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(leftSlideScale, "Scale"); MadGUI.PropertyFieldVector2(leftSlideOffset, "Offset"); }); MadGUI.PropertyField(rightSlideSprite, "Next Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(rightSlideScale, "Scale"); MadGUI.PropertyFieldVector2(rightSlideOffset, "Offset"); }); }); EditorGUILayout.Space(); GUILayout.Label("Dimensions", "HeaderLabel"); using (MadGUI.Indent()) { MadGUI.PropertyField(pixelsWidth, "Pixels Width"); MadGUI.PropertyField(pixelsHeight, "Pixels Height"); EditorGUILayout.Space(); GUI.enabled = generate; MadGUI.PropertyField(gridHeight, "Grid Rows"); MadGUI.PropertyField(gridWidth, "Grid Columns"); EditorGUILayout.Space(); MadGUI.PropertyField(limitLevelsPerPage, "Limit Levels Per Page"); using (MadGUI.EnabledIf(script.limitLevelsPerPage)) { MadGUI.PropertyField(levelsPerPage, "Levels Per Page"); } EditorGUILayout.Space(); MadGUI.PropertyFieldEnumPopup(horizontalAlign, "Horizontal Align"); MadGUI.PropertyFieldEnumPopup(verticalAlign, "Vertical Align"); GUI.enabled = true; EditorGUILayout.Space(); } GUILayout.Label("Paging", "HeaderLabel"); using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(pagingMethod, "Paging Method"); using (MadGUI.Indent()) { MadGUI.PropertyField(pagingInvert, "Invert"); if (IsPagingMethodZoom()) { MadGUI.PropertyField(pagesZoomScale, "Zoom Scale"); } } EditorGUILayout.Space(); MadGUI.PropertyField(pagesOffsetFromResolution, "Dynamic Offset"); using (MadGUI.Indent()) { if (pagesOffsetFromResolution.boolValue) { MadGUI.PropertyFieldSlider(pagesOffsetPercent, 0, 2, "Offset %"); } else { MadGUI.PropertyField(pagesOffsetManual, "Pixels Offset"); } } } EditorGUILayout.Space(); GUILayout.Label("Mechanics", "HeaderLabel"); MadGUI.Indent(() => { LookAtLastLevel(); EditorGUILayout.Space(); HandleMobileBack(); EditorGUILayout.Space(); TwoStepActivation(); EditorGUILayout.Space(); LoadLevel(); }); GUILayout.Label("Debug", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(hideManagerdObjects, "Hide Managed", "Hides managed by Mad Level Manager objects from the Hierarchy. If you want to have a look at what the hierarchy " + "looks like exacly, you can unckeck this option. Be aware that all direct changes to generated " + "objects will be lost!"); }); serializedObject.ApplyModifiedProperties(); }
override public void ShowGUI(List <ActionParameter> parameters) { if (sceneSettings == null) { EditorGUILayout.HelpBox("No 'Scene Settings' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info); AfterRunningOption(); return; } sceneSetting = (SceneSetting)EditorGUILayout.EnumPopup("Scene setting to change:", sceneSetting); if (sceneSetting == SceneSetting.DefaultNavMesh) { if (sceneSettings.navigationMethod == AC_NavigationMethod.meshCollider || sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider) { if (sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider) { changeNavMeshMethod = (ChangeNavMeshMethod)EditorGUILayout.EnumPopup("Change NavMesh method:", changeNavMeshMethod); } if (sceneSettings.navigationMethod == AC_NavigationMethod.meshCollider || changeNavMeshMethod == ChangeNavMeshMethod.ChangeNavMesh) { parameterID = Action.ChooseParameterGUI("New NavMesh:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; newNavMesh = null; } else { newNavMesh = (NavigationMesh)EditorGUILayout.ObjectField("New NavMesh:", newNavMesh, typeof(NavigationMesh), true); constantID = FieldToID <NavigationMesh> (newNavMesh, constantID); newNavMesh = IDToField <NavigationMesh> (newNavMesh, constantID, false); } } else if (changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles) { holeAction = (InvAction)EditorGUILayout.EnumPopup("Add or remove hole:", holeAction); string _label = "Hole to add:"; if (holeAction == InvAction.Remove) { _label = "Hole to remove:"; } parameterID = Action.ChooseParameterGUI(_label, parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; hole = null; } else { hole = (PolygonCollider2D)EditorGUILayout.ObjectField(_label, hole, typeof(PolygonCollider2D), true); constantID = FieldToID <PolygonCollider2D> (hole, constantID); hole = IDToField <PolygonCollider2D> (hole, constantID, false); } if (holeAction == InvAction.Replace) { replaceParameterID = Action.ChooseParameterGUI("Hole to remove:", parameters, replaceParameterID, ParameterType.GameObject); if (replaceParameterID >= 0) { replaceConstantID = 0; replaceHole = null; } else { replaceHole = (PolygonCollider2D)EditorGUILayout.ObjectField("Hole to remove:", replaceHole, typeof(PolygonCollider2D), true); replaceConstantID = FieldToID <PolygonCollider2D> (replaceHole, replaceConstantID); replaceHole = IDToField <PolygonCollider2D> (replaceHole, replaceConstantID, false); } } } } else { EditorGUILayout.HelpBox("This action is not compatible with the Unity Navigation pathfinding method, as set in the Scene Manager.", MessageType.Warning); } } else if (sceneSetting == SceneSetting.DefaultPlayerStart) { parameterID = Action.ChooseParameterGUI("New default PlayerStart:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; playerStart = null; } else { playerStart = (PlayerStart)EditorGUILayout.ObjectField("New default PlayerStart:", playerStart, typeof(PlayerStart), true); constantID = FieldToID <PlayerStart> (playerStart, constantID); playerStart = IDToField <PlayerStart> (playerStart, constantID, false); } } else if (sceneSetting == SceneSetting.SortingMap) { parameterID = Action.ChooseParameterGUI("New SortingMap:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; sortingMap = null; } else { sortingMap = (SortingMap)EditorGUILayout.ObjectField("New SortingMap:", sortingMap, typeof(SortingMap), true); constantID = FieldToID <SortingMap> (sortingMap, constantID); sortingMap = IDToField <SortingMap> (sortingMap, constantID, false); } } else if (sceneSetting == SceneSetting.TintMap) { parameterID = Action.ChooseParameterGUI("New TintMap:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; tintMap = null; } else { tintMap = (TintMap)EditorGUILayout.ObjectField("New TintMap:", tintMap, typeof(TintMap), true); constantID = FieldToID <TintMap> (tintMap, constantID); tintMap = IDToField <TintMap> (tintMap, constantID, false); } } else if (sceneSetting == SceneSetting.OnLoadCutscene) { parameterID = Action.ChooseParameterGUI("New OnLoad cutscene:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; cutscene = null; } else { cutscene = (Cutscene)EditorGUILayout.ObjectField("New OnLoad cutscene:", cutscene, typeof(Cutscene), true); constantID = FieldToID <Cutscene> (cutscene, constantID); cutscene = IDToField <Cutscene> (cutscene, constantID, false); } } else if (sceneSetting == SceneSetting.OnStartCutscene) { parameterID = Action.ChooseParameterGUI("New OnStart cutscene:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; cutscene = null; } else { cutscene = (Cutscene)EditorGUILayout.ObjectField("New OnStart cutscene:", cutscene, typeof(Cutscene), true); constantID = FieldToID <Cutscene> (cutscene, constantID); cutscene = IDToField <Cutscene> (cutscene, constantID, false); } } AfterRunningOption(); }
/// <summary> /// Helper method for rendering various controls. /// </summary> /// <param name="type"></param> /// <param name="value"></param> /// <param name="content"></param> public static int AnyField(Type type, ref object value, GUIContent content) { if (type == typeof(bool)) { value = EditorGUILayout.Toggle(content, (bool)value); } else if (type == typeof(byte)) { value = (byte)EditorGUILayout.DelayedIntField(content, (byte)value); } else if (type == typeof(short)) { value = (short)EditorGUILayout.DelayedIntField(content, (short)value); } else if (type == typeof(ushort)) { value = (ushort)EditorGUILayout.DelayedIntField(content, (ushort)value); } else if (type == typeof(int)) { value = EditorGUILayout.IntField(content, (int)value); } else if (type == typeof(uint)) { value = (uint)EditorGUILayout.IntField(content, (int)value); } else if (type == typeof(long)) { value = EditorGUILayout.LongField(content, (long)value); } else if (type == typeof(ulong)) { value = (ulong)EditorGUILayout.LongField(content, (long)value); } else if (type == typeof(float)) { value = EditorGUILayout.FloatField(content, (float)value); } else if (type == typeof(double)) { value = EditorGUILayout.DoubleField(content, (double)value); } else if (type == typeof(string)) { value = EditorGUILayout.TextField(content, (string)value); } else if (TypeHelper.IsSameOrSubclass(typeof(Enum), type)) { value = EditorGUILayout.EnumPopup(content, (Enum)value); } else if (type == typeof(Vector2)) { value = EditorGUILayout.Vector2Field(content, (Vector2)value); } else if (type == typeof(Vector3)) { value = EditorGUILayout.Vector3Field(content, (Vector3)value); } else if (type == typeof(Vector4)) { value = EditorGUILayout.Vector4Field(content, (Vector4)value); } else if (type == typeof(Quaternion)) { Quaternion q = (Quaternion)value; q.eulerAngles = EditorGUILayout.Vector3Field(content, ((Quaternion)value).eulerAngles); value = q; } else if (type == typeof(Color)) { value = EditorGUILayout.ColorField(content, (Color)value); } else if (type == typeof(Bounds)) { value = EditorGUILayout.BoundsField(content, (Bounds)value); } else if (type == typeof(Rect)) { value = EditorGUILayout.RectField(content, (Rect)value); } else if (type == typeof(AnimationCurve)) { value = EditorGUILayout.CurveField(content, (AnimationCurve)value); } else if (TypeHelper.IsSameOrSubclass(typeof(UnityEngine.Object), type)) { value = EditorGUILayout.ObjectField(content, (UnityEngine.Object)value, type, true); } else if (type == typeof(LayerMask)) { value = LayerMaskField(content, (LayerMask)value); } else { return(ComplexField(content, value)); } //TODO: general EnumMask, Assets (Sprite, Texture, etc...) return(1); }
private void OnGUI() { GUILayout.Label("保存路径"); GUILayout.BeginHorizontal(); path = GUILayout.TextField(path); if (GUILayout.Button("选择文件夹")) { string selectPath = EditorUtility.OpenFolderPanel("资源保持路径", Application.dataPath, ""); if (!string.IsNullOrEmpty(selectPath)) { path = selectPath; } } GUILayout.EndHorizontal(); GUILayout.Label("打包平台"); platform = (BuildTarget)EditorGUILayout.EnumPopup(platform); GUILayout.Label("压缩方式"); option = (BuildAssetBundleOptions)EditorGUILayout.EnumPopup(option); scrollPos = GUILayout.BeginScrollView(scrollPos); for (int i = 0; i < bundles.Length; i++) { bool isBuild = selectBunldes.Contains(bundles[i]); bool isTrue = GUILayout.Toggle(isBuild, bundles[i]); if (isBuild != isTrue) { if (isTrue) { selectBunldes.Add(bundles[i]); } else { selectBunldes.Remove(bundles[i]); } } } GUILayout.EndScrollView(); GUILayout.Label("版本信息"); version = GUILayout.TextField(version); // if (GUILayout.Button("生成Hotfix字节文件")) // { // GenHotfix(); // AssetDatabase.Refresh(); // } if (GUILayout.Button("打包")) { AssetBundleBuild[] builds = new AssetBundleBuild[selectBunldes.Count]; for (int i = 0; i < builds.Length; i++) { AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = selectBunldes[i]; build.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(build.assetBundleName); builds[i] = build; } AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(GetTargetPath(platform), builds, option, platform); Dictionary <string, Hash128> hash = FileUtil.LoadABManifest(manifest); CreateConfig(hash); AssetDatabase.Refresh(); } }
protected void DrawFooter() { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(EditorStyles.toolbar); { Color color = GUI.contentColor; GUI.contentColor = EditorGUIUtility.isProSkin ? new Color(0.9f, 0.9f, 0.9f, 1f) : new Color(0.1f, 0.1f, 0.1f, 1f); if (FR2_Unity.DrawToggleToolbar(ref FR2_Setting.showSettings, Icon.icons.Setting, 21f)) { maskDirty(); if (FR2_Setting.showSettings) { showFilter = showIgnore = false; } } GUI.contentColor = color; bool v = checkNoticeFilter(); string content = !FR2_Setting.IsIncludeAllType() ? "*Filter" : "Filter"; if (v) { Color oc = GUI.backgroundColor; GUI.backgroundColor = Color.red; v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); GUI.backgroundColor = oc; } else { v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); } if (v != showFilter) { showFilter = v; if (showFilter) { FR2_Setting.showSettings = showIgnore = false; } } v = checkNoticeIgnore(); content = FR2_Setting.IgnoreAsset.Count > 0 ? "*Ignore" : "Ignore"; if (v) { Color oc = GUI.backgroundColor; GUI.backgroundColor = Color.red; v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); GUI.backgroundColor = oc; } else { v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); } // var i = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); if (v != showIgnore) { showIgnore = v; if (v) { showFilter = FR2_Setting.showSettings = false; } } bool ss = FR2_Setting.ShowSelection; v = GUILayout.Toggle(ss, "Selection", EditorStyles.toolbarButton, GUILayout.Width(60f)); if (v != ss) { FR2_Setting.ShowSelection = v; maskDirty(); } if (FR2_Selection.SelectionCount > 0) { if (GUILayout.Button("Commit Selection [" + FR2_Selection.SelectionCount + "]", EditorStyles.toolbarButton)) { FR2_Selection.Commit(); } if (GUILayout.Button("Clear Selection", EditorStyles.toolbarButton)) { FR2_Selection.ClearSelection(); } } GUILayout.FlexibleSpace(); if (!IsFocusingDuplicate && !IsFocusingGUIDs) { float o = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 42f; FR2_RefDrawer.Mode ov = FR2_Setting.GroupMode; var vv = (FR2_RefDrawer.Mode)EditorGUILayout.EnumPopup("Group", ov, GUILayout.Width(122f)); if (vv != ov) { FR2_Setting.GroupMode = vv; maskDirty(); } GUILayout.Space(4f); EditorGUIUtility.labelWidth = 30f; FR2_RefDrawer.Sort s = FR2_Setting.SortMode; var vvv = (FR2_RefDrawer.Sort)EditorGUILayout.EnumPopup("Sort", s, GUILayout.Width(100f)); if (vvv != s) { FR2_Setting.SortMode = vvv; RefreshSort(); } EditorGUIUtility.labelWidth = o; } } GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(listFolded ? "+" : "-", GUILayout.Height(15f), GUILayout.Width(18f))) { listFolded = !listFolded; } EditorGUILayout.LabelField("UIResourceDataBase"); EditorGUILayout.EndHorizontal(); List <UIResource> removeList = new List <UIResource>(); if (!listFolded) { foreach (var r in Target.UIResourceDatabase) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("->", GUILayout.Width(20f)); if (GUILayout.Button(r.editorFolded ? "+" : "-", GUILayout.Height(15f), GUILayout.Width(18f))) { r.editorFolded = !r.editorFolded; } EditorGUILayout.LabelField(r.resourceLocator + "-------------------------------------------------------------------------------------------------------------"); if (r.editorFolded) { switch (r.contentType) { case UIContentType.Text: r.text = EditorGUILayout.TextField(r.text); break; case UIContentType.Image: r.image = (Sprite)EditorGUILayout.ObjectField(r.image, typeof(Sprite)); break; case UIContentType.Texture2D: r.texture = (Texture2D)EditorGUILayout.ObjectField(r.texture, typeof(Texture2D)); break; case UIContentType.OnOffCommand: r.onOffCommand = EditorGUILayout.Toggle(r.onOffCommand); break; default: break; } } else { if (GUILayout.Button("del", GUILayout.Height(15f), GUILayout.Width(48f))) { removeList.Add(r); } } EditorGUILayout.EndHorizontal(); if (!r.editorFolded) { r.resourceLocator = EditorGUILayout.TextField("Locator", r.resourceLocator); r.contentType = (UIContentType)EditorGUILayout.EnumPopup("Content Type", r.contentType); switch (r.contentType) { case UIContentType.Text: r.text = EditorGUILayout.TextField("Text", r.text); break; case UIContentType.Image: r.image = (Sprite)EditorGUILayout.ObjectField("Image", r.image, typeof(Sprite)); break; case UIContentType.Texture2D: r.texture = (Texture2D)EditorGUILayout.ObjectField(r.texture, typeof(Texture2D)); break; case UIContentType.OnOffCommand: r.onOffCommand = EditorGUILayout.Toggle("OnOff Cmd", r.onOffCommand); break; default: break; } EditorGUILayout.Space(); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add")) { var r = new UIResource(); r.resourceLocator = "www..."; r.contentType = UIContentType.Text; Target.UIResourceDatabase.Add(r); } EditorGUILayout.EndHorizontal(); } foreach (var r in removeList) { Target.UIResourceDatabase.Remove(r); } if (GUI.changed) { EditorUtility.SetDirty(target); } }