protected override bool RenderInternal(RenderComposer c) { if (!base.RenderInternal(c)) { return(false); } c.SetClipRect(new Rectangle(Position, Size)); EditorHelpers.RenderToolGrid(c, Position, Size, _calculatedColor, (int)Maths.RoundClosest(DebugGridSize * GetScale())); c.SetClipRect(null); Vector2 posVec2 = Position.ToVec2(); c.RenderLine(posVec2 + new Vector2(Size.X / 2, 0), posVec2 + new Vector2(Size.X / 2, Size.Y), Color.White * 0.7f); c.RenderLine(posVec2 + new Vector2(0, Size.Y / 2), posVec2 + new Vector2(Size.X, Size.Y / 2), Color.White * 0.7f); return(true); }
static void CreatePartAssetBundles(GameObject fbx, string name) { List <Material> materials = EditorHelpers.CollectAll <Material>(MaterialsPath(fbx)); foreach (SkinnedMeshRenderer smr in fbx.GetComponentsInChildren <SkinnedMeshRenderer>(true)) { List <Object> toinclude = new List <Object>(); GameObject rendererClone = (GameObject)PrefabUtility.InstantiatePrefab(smr.gameObject); GameObject rendererParent = rendererClone.transform.parent.gameObject; rendererClone.transform.parent = null; Object.DestroyImmediate(rendererParent); Object rendererPrefab = GetPrefab(rendererClone, "rendererobject"); toinclude.Add(rendererPrefab); // 若材质对象名称中包含子对象的名称(如eyes、face-1、face-2等则 // 视将材质对象加入列表。这里注意每个toinclude对象与一个 // SkinnedMeshRenderer对象对应,即与FBX对象的子对象对应。 foreach (Material m in materials) { if (m.name.Contains(smr.name.ToLower())) { toinclude.Add(m); } } List <string> boneNames = new List <string>(); foreach (Transform t in smr.bones) { boneNames.Add(t.name); } string stringholderpath = "Assets/bonenames.asset"; StringHolder holder = ScriptableObject.CreateInstance <StringHolder> (); holder.content = boneNames.ToArray(); AssetDatabase.CreateAsset(holder, stringholderpath); toinclude.Add(AssetDatabase.LoadAssetAtPath(stringholderpath, typeof(StringHolder))); string bundleName = name + "_" + smr.name.ToLower(); string path = AssetbundlePath + bundleName + ".assetbundle"; BuildPipeline.BuildAssetBundle(null, toinclude.ToArray(), path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(rendererPrefab)); AssetDatabase.DeleteAsset(stringholderpath); } }
public async Task BitOwnershipHelperCheckOneBitWithSameAddress() { List <IConfigurationItemViewModel> list = new List <IConfigurationItemViewModel>(); var property = EditorHelpers.AddPropertyViewModel(list, 1, _typesContainer); var secondProp = EditorHelpers.AddPropertyViewModel(list, 1, _typesContainer); secondProp.IsFromBits = true; property.IsFromBits = true; secondProp.BitNumbersInWord[15].IsChecked = true; var res = BitOwnershipHelper.CreateBitViewModelsWithOwnership( property, list); Assert.False(res[15].IsBitEditEnabled); Assert.True(res.Where(model => model != res[15]).All(model => model.IsBitEditEnabled)); }
void DrawCategory() { contentColor = GUI.contentColor; backgroundColor = GUI.backgroundColor; string oldStringValue = string.Empty; int oldIntValue = 0; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID:", GUILayout.Width(100)); oldStringValue = category.id; category.id = EditorGUILayout.TextField(category.id, GUILayout.Width(150)); if (category.id != oldStringValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Name:", GUILayout.Width(100)); oldStringValue = category.name; category.name = EditorGUILayout.TextField(category.name, GUILayout.Width(150)); if (category.name != oldStringValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Index:", GUILayout.Width(100)); oldIntValue = category.index; category.index = EditorGUILayout.IntField(category.index, GUILayout.Width(150)); if (category.index != oldIntValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorHelpers.DrawListOfGameElemetData("Restrictions:", category.restrictions, ref dirty); EditorGUILayout.Separator(); EditorHelpers.DrawListOfAssetData("Assets:", category.assets, ref dirty); EditorGUILayout.Separator(); EditorHelpers.DrawListOfGenericPropertyData("Properties:", category.properties, ref dirty); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); }
public override void LoadParts(Editor parent) { foreach (DungeonPart part in Parts) { object imageList = part.Definition[1]; // If the format isn't strictly correct, assume there's only one layer in this part // We must do this because some dungeon authors do not create an array if there // is only one layer to their part. if (imageList is string) { JArray tempArray = new JArray { imageList }; imageList = tempArray; } // For each defined image foreach (string fileName in (JArray)imageList) { string path = EditorHelpers.ParsePath(Path.GetDirectoryName(FilePath), fileName); if (!File.Exists(path)) { continue; } Image layerImg = EditorHelpers.LoadImageFromFile(path); // Set the width and height of the part to match the blockmap part.Width = layerImg.Width; part.Height = layerImg.Height; part.Layers.Add(new EditorMapLayer(fileName, (Bitmap)layerImg, parent.BrushMap, part)); } // Create the graphics image part.GraphicsMap = new Bitmap(part.Width * Editor.DEFAULT_GRID_FACTOR, part.Height * Editor.DEFAULT_GRID_FACTOR); // Update the composite collision map, now that all layers have been loaded part.UpdateCompositeCollisionMap(); part.Parent = this; } }
static void LoadIcons() { actionNodeIcon = EditorHelpers.LoadGraphic("createActionNodeIcon.png"); coroutineNodeIcon = EditorHelpers.LoadGraphic("createCoroutineNodeIcon.png"); eventNodeIcon = EditorHelpers.LoadGraphic("createEventNodeIcon.png"); wizardIcon = EditorHelpers.LoadGraphic("nodeWizardIcon.png"); nodeTypesIcons = new Texture2D[3]; nodeTypesIcons[0] = actionNodeIcon; nodeTypesIcons[1] = coroutineNodeIcon; nodeTypesIcons[2] = eventNodeIcon; nodeOutputs = new List <string>(); nodeOutputs.Add(""); FindNodeModules(); }
public void OnPreprocessBuild(BuildTarget target, string path) { EditorHelpers.SetPluginName("UniversalDeepLinking"); var processor = GetProcessor(target); if (processor == null) { return; } AppLinkingConfiguration configuration = Storage.ConfigurationStorage.Load(); processor.OnPreprocessBuild(configuration, path); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float height = EditorGUIUtility.singleLineHeight; if (property.isExpanded == true) { // Grab every field SerializedProperty key = property.FindPropertyRelative("key"); SerializedProperty dictionary = property.FindPropertyRelative("dictionary"); // Allocate key field height += EditorHelpers.GetHeight(2); // Update status TranslationDictionary translationDictionary = dictionary.objectReferenceValue as TranslationDictionary; string translationKey = key.stringValue; Status status = UpdateMessageStatus(translationDictionary, translationKey); // Check status if (string.IsNullOrEmpty(Message) == false) { // Allocate help box height += EditorHelpers.VerticalMargin; height += EditorHelpers.GetHelpBoxHeight(Message, Width); } // Check button if (IsButtonDrawn(status) == true) { // Allocate button height += EditorHelpers.VerticalMargin; height += ButtonHeight; } // Check preview if (IsTextPreviewDrawn(status) == true) { // Allocate preview height += EditorHelpers.VerticalSpace; height += EditorGUIUtility.singleLineHeight; height += TextPreview.CalculateHeight(null, !translationDictionary.IsAllTranslationsSerialized); } } return(height); }
protected override bool PostAnchorGUI(AnchoredJoint2D joint2D, AnchorInfo info, List <Vector2> otherAnchors, JointHelpers.AnchorBias bias) { var wheelJoint2D = joint2D as WheelJoint2D; if (wheelJoint2D == null) { return(false); } var suspensionAngleControlID = info.GetControlID("suspensionAngle"); if (Event.current.type == EventType.repaint) { if (EditorHelpers.IsWarm(suspensionAngleControlID) && DragAndDrop.objectReferences.Length == 0) { var suspensionAngle = wheelJoint2D.suspension.angle; var labelContent = new GUIContent(String.Format("{0:0.00}", suspensionAngle)); Vector3 mainAnchorPosition = Helpers2D.GUIPointTo2DPosition(Event.current.mousePosition); var fontSize = HandleUtility.GetHandleSize(mainAnchorPosition) * (1f / 64f); var labelOffset = fontSize * EditorHelpers.FontWithBackgroundStyle.CalcSize(labelContent).y; EditorHelpers.OverlayLabel(mainAnchorPosition + (Camera.current.transform.up * labelOffset), labelContent, EditorHelpers.FontWithBackgroundStyle); } } else { if (EditorHelpers.IsWarm(suspensionAngleControlID) && DragAndDrop.objectReferences.Length == 0) { if (SceneView.lastActiveSceneView) { SceneView.lastActiveSceneView.Repaint(); } } } return(false); }
private void UpdateLayersView() { LayersListBox.SuspendLayout(); LayersListBox.BeginUpdate(); LayersListBox.Items.Clear(); //Early out if the worldspace project is null (ie: We just unloaded the project) if (_loadedWorldspaceProject == null) { LayersListBox.EndUpdate(); LayersListBox.ResumeLayout(); return; } WindWakerEntityData entData = _selectedEntityFile; List <EditorHelpers.EntityLayer> validLayers = new List <EditorHelpers.EntityLayer>(); foreach (var kvPair in entData.GetAllChunks()) { foreach (WindWakerEntityData.BaseChunk chunk in kvPair.Value) { if (validLayers.Contains(chunk.ChunkLayer)) { continue; } validLayers.Add(chunk.ChunkLayer); } } for (int i = validLayers.Count - 1; i >= 0; i--) { LayersListBox.Items.Add(EditorHelpers.LayerIdToString(validLayers[i])); } //Select the Default layer by uh... default. if (LayersListBox.Items.Count > 0) { LayersListBox.SetSelected(LayersListBox.Items.Count - 1, true); } LayersListBox.ResumeLayout(); LayersListBox.EndUpdate(); }
private void LimitContext(HingeJoint2D hingeJoint2D, int controlID, Limit limit) { var mousePosition = Event.current.mousePosition; var limitName = (limit == Limit.Min ? "Lower" : "Upper") + " Angle Limit"; EditorHelpers.ContextClick(controlID, () => { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Edit " + limitName), false, () => ShowUtility( "Edit " + limitName, new Rect(mousePosition.x - 250, mousePosition.y + 15, 500, EditorGUIUtility.singleLineHeight * 2), delegate(Action close, bool focused) { EditorGUI.BeginChangeCheck(); GUI.SetNextControlName(limitName); var newLimit = EditorGUILayout.FloatField(limitName, limit == Limit.Min ? hingeJoint2D.limits.min : hingeJoint2D.limits.max); if (EditorGUI.EndChangeCheck()) { var limits = hingeJoint2D.limits; if (limit == Limit.Min) { limits.min = newLimit; } else { limits.max = newLimit; } EditorHelpers.RecordUndo(limitName, hingeJoint2D); hingeJoint2D.limits = limits; EditorUtility.SetDirty(hingeJoint2D); } if (GUILayout.Button("Done") || (Event.current.isKey && (Event.current.keyCode == KeyCode.Escape) && focused)) { close(); } })); menu.ShowAsContext(); }); }
public void ValidateEditorConfigurationWithMissingResource() { IResultingDeviceViewModel initialDevice = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>(); var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>( ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION + ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel; var rootGroup = new ConfigurationGroupEditorViewModel() { Name = "root" }; EditorHelpers.AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 1); configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup); initialDevice.FragmentEditorViewModels .Add(configurationEditorViewModel); var res = _typesContainer.Resolve <IDeviceEditorViewModelValidator>() .ValidateDeviceEditor(new List <IFragmentEditorViewModel>() { configurationEditorViewModel }); Assert.True(res.Count == 1); var newDevice = initialDevice.GetDevice(); IResultingDeviceViewModel newDeviceViewModel = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>(); newDeviceViewModel.LoadDevice(newDevice); var resNew = _typesContainer.Resolve <IDeviceEditorViewModelValidator>() .ValidateDeviceEditor(new List <IFragmentEditorViewModel>() { newDeviceViewModel.FragmentEditorViewModels.First() }); Assert.True(resNew.Count == 1); }
void OnEnable() { _eventName = serializedObject.FindProperty("EventName"); _eventListener = serializedObject.FindProperty("EventListener"); _duplicateEventListener = serializedObject.FindProperty("DuplicateEventListener"); _eventListenerPropertyType = serializedObject.FindProperty("EventListenerPropertyType"); _receiveEventState = serializedObject.FindProperty("ReceiveEventState"); _eventMap = FindObjectOfType <EventMap>(); if (_eventMap == null) { Debug.LogError("Please add an EventMap to your scene"); } // Get all of the event handlers in the scene // Event handlers are scripts that implement IGameObjectPropertyEventHandler _eventHandlers = EditorHelpers.GetTypesInScene(ReflectionHelpers.GetTypesThatImplementInterface(typeof(IEventListener <>))); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { const string ButtonString = "Button"; const string TextString = "Text"; var Btn = property.FindPropertyRelative("Btn"); var Txt = property.FindPropertyRelative("Txt"); var LabelString = EditorHelpers.GetStringLengthinPix(label.text); var ButtonStringLength = EditorHelpers.GetStringLengthinPix(ButtonString); var TextStringLength = EditorHelpers.GetStringLengthinPix(TextString); var halfRowWidthForData = (position.width - LabelString) / 2; EditorGUI.LabelField(new Rect(position.x, position.y, LabelString, singleLine), label); EditorGUI.LabelField(new Rect(position.x + LabelString, position.y, ButtonStringLength, singleLine), ButtonString); EditorGUI.PropertyField(new Rect(position.x + LabelString + ButtonStringLength, position.y, halfRowWidthForData - ButtonStringLength, singleLine), Btn, GUIContent.none); EditorGUI.LabelField(new Rect(position.x + halfRowWidthForData + LabelString, position.y, TextStringLength, singleLine), TextString); EditorGUI.PropertyField(new Rect(position.x + LabelString + halfRowWidthForData + TextStringLength, position.y, halfRowWidthForData - TextStringLength, singleLine), Txt, GUIContent.none); property.serializedObject.ApplyModifiedProperties(); }
private void DisplayAbilitySet() { var abilities = EditorHelpers.GetScriptAssetsOfType <BossAbility>(); if (bossProps.AbilitySet == null || bossProps.AbilitySet.Length == 0) { bossProps.AbilitySet = new MonoScript[1]; bossProps.AbilitySet[0] = abilities[0]; } var abilityInspectorIndex = EditorHelpers.GetIndexFromObject(abilities, bossProps.AbilitySet[0]); // TODO cycle through all var abilityArray = EditorHelpers.ObjectArrayToStringArray(abilities); EditorGUILayout.LabelField("Abilities"); int abilityIndex = EditorGUILayout.Popup("Ability 1", abilityInspectorIndex, abilityArray); bossProps.AbilitySet[0] = abilities[abilityIndex]; }
protected override void ReAlignAnchors(AnchoredJoint2D joint2D, JointHelpers.AnchorBias alignmentBias) { var wheelJoint2D = (WheelJoint2D)joint2D; //align the angle to the connected anchor var direction = JointHelpers.GetConnectedAnchorPosition(joint2D) - JointHelpers.GetMainAnchorPosition(joint2D); if (direction.magnitude > AnchorEpsilon) { var wantedAngle = Helpers2D.GetAngle(direction); EditorHelpers.RecordUndo("Realign angle", wheelJoint2D); var susp = wheelJoint2D.suspension; susp.angle = wantedAngle - wheelJoint2D.transform.eulerAngles.z; wheelJoint2D.suspension = susp; } }
void DrawItem() { contentColor = GUI.contentColor; backgroundColor = GUI.backgroundColor; string oldStringValue = string.Empty; int oldIntValue = 0; float oldFloatValue = 0; bool oldBoolValue = true; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID:", GUILayout.Width(100)); oldStringValue = leaderboardData.id; leaderboardData.id = EditorGUILayout.TextField(leaderboardData.id, GUILayout.Width(150)); if (leaderboardData.id != oldStringValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Name:", GUILayout.Width(100)); oldStringValue = leaderboardData.name; leaderboardData.name = EditorGUILayout.TextField(leaderboardData.name, GUILayout.Width(150)); if (leaderboardData.name != oldStringValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Leaderboard ID:", GUILayout.Width(100)); oldStringValue = leaderboardData.leaderboardId; leaderboardData.leaderboardId = EditorGUILayout.TextField(leaderboardData.leaderboardId, GUILayout.Width(150)); if (leaderboardData.leaderboardId != oldStringValue) { dirty = true; } EditorGUILayout.EndHorizontal(); EditorHelpers.DrawStringAsPopup("Store:", ref leaderboardData.store, EditorHelpers.storeNames, ref dirty); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); }
private void OnGUI() { EditorGUILayout.HelpBox("The following field has been drawn with MuffinDevGUI.ExtendedObjectField().\nUse the added controls to, from left to right:\n\t- Show/hide informations about the selected asset\n\t- Lock/unlock the selected asset\n\t- Focus the asset in the project view\n\t- Create a new asset if applicable", MessageType.Info); EditorGUILayout.Space(); bool locked = m_Object != null && m_Locked; bool canChangeFoldState = m_Object != null; bool canFocus = m_Object != null; bool canCreate = m_Object != null ? m_Object is ScriptableObject : false; GUI.enabled = !locked; m_Object = MuffinDevGUI.ExtendedObjectField("Selected Asset", m_Object, typeof(Object), true, new ExtendedObjectFieldButton[] { // Add "Fold/Unfold" button new ExtendedObjectFieldButton(m_Folded ? EEditorIcon.Unfold : EEditorIcon.Fold, ExtendedObjectFieldButton.EPosition.BeforeLabel, m_Folded ? "Hide informations" : "Show informations", () => { m_Folded = !m_Folded; }, canChangeFoldState), // Add "Focus" button new ExtendedObjectFieldButton(locked ? EEditorIcon.Lock : EEditorIcon.Unlock, ExtendedObjectFieldButton.EPosition.BeforeField, locked ? "Locked" : "Unlocked", locked ? "Unlock selected asset" : "Lock selected asset", () => { m_Locked = !m_Locked; }, m_Object != null), // Add "Focus" button new ExtendedObjectFieldButton(EEditorIcon.Focus, ExtendedObjectFieldButton.EPosition.AfterField, "Focus asset", () => { EditorHelpers.FocusAsset(m_Object, true, true); }, canFocus), // Add "Create" button new ExtendedObjectFieldButton(EEditorIcon.Add, ExtendedObjectFieldButton.EPosition.AfterField, $"Create new {(m_Object != null ? m_Object.GetType().Name : "Object")} asset", () => { if (m_Object != null) { EditorHelpers.CreateAssetPanel(m_Object.GetType(), out Object newAsset, $"Create new {m_Object.GetType().Name} asset", $"New{m_Object.GetType().Name}", "", "asset", false); if (newAsset != null) { m_Object = newAsset; } } }, canCreate)
/// <summary> /// Refreshes the displayed assets list, and apply the registered filters. /// </summary> public void Refresh() { m_Assets = EditorHelpers.FindAllAssetsOfType <T>(); List <T> filteredAssets = new List <T>(); foreach (Func <T, bool> filter in m_Filters) { filteredAssets.Clear(); foreach (T asset in m_Assets) { if (filter(asset)) { filteredAssets.Add(asset); } } m_Assets = filteredAssets.ToArray(); } }
// Draw custom node inspector public override void DrawCustomInspector() { using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box"))) { GUILayout.Label("File Name:"); fileName = GUILayout.TextField(fileName); } using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box"))) { GUILayout.Label("Save Path:"); loadPath = (FlowReactor.BlackboardSystem.BlackBoard.SavePath)EditorGUILayout.EnumPopup(loadPath); } using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box"))) { GUILayout.Label("Format:"); loadFormat = (FlowReactor.BlackboardSystem.BlackBoard.SaveFormat)EditorGUILayout.EnumPopup(loadFormat); } EditorHelpers.DrawUILine(); GUILayout.Label("Blackboards"); if (GUILayout.Button("Add")) { blackboards.Add(null); } for (int b = 0; b < blackboards.Count; b++) { using (new GUILayout.HorizontalScope("Box")) { if (blackboards[b] != null) { GUILayout.Label(blackboards[b].name); } blackboards[b] = (BlackBoard)EditorGUILayout.ObjectField(blackboards[b], typeof(BlackBoard), false); if (GUILayout.Button("x")) { blackboards.RemoveAt(b); } } } }
private ReorderableList GetFontsList(SerializedProperty property) { // Attempt to retrieve the list ReorderableList fontsList = null; if (fonts.TryGetValue(property, out fontsList) == false) { // If none is found, create a new one fontsList = new ReorderableList(serializedObject, property, true, true, true, true); fontsList.drawHeaderCallback = DrawFontsListHeader; fontsList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { DrawFontsListElement(property.GetArrayElementAtIndex(index), rect); }; fontsList.elementHeight = EditorHelpers.SingleLineHeight(EditorHelpers.VerticalMargin); fonts.Add(property, fontsList); } return(fontsList); }
public override void OnInspectorGUI() { var transform = target as Transform; serializedObject.Update(); EditorGUILayout.BeginHorizontal("Box"); transform = EditorHelpers.CopyPastObjectButtons(transform) as Transform; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); var ResetContent = new GUIContent("Reset Transform", "Reset Transforms in global space"); var ResetLocalContent = new GUIContent("Reset Local Transform", "Reset Transforms in local space"); if (GUILayout.Button(ResetContent)) { transform.ResetPosRotScale(); } if (GUILayout.Button(ResetLocalContent)) { transform.ResetLocalPosRotScale(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(); scaleToggle = EditorGUILayout.Toggle("Scale Presets", scaleToggle); if (scaleToggle) { ScaleBtnsEnabled(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorHelpers.Label(transform.parent == null? "Transform" : "Local Transform"); transform.localEulerAngles = EditorHelpers.DrawVector3("Rotation", transform.localEulerAngles, Vector3.zero); transform.localPosition = EditorHelpers.DrawVector3("Position", transform.localPosition, Vector3.zero); transform.localScale = EditorHelpers.DrawVector3("Scale ", transform.localScale, Vector3.one); serializedObject.ApplyModifiedProperties(); }
private void DrawArchiveContents() { EditorHelpers.DrawBoldFoldout(contentAnimation, "Archive Contents"); // Draw the rest of the controls using (EditorGUILayout.FadeGroupScope fadeScope = new EditorGUILayout.FadeGroupScope(contentAnimation.faded)) { if (fadeScope.visible == true) { // Draw the rest of the controls EditorGUILayout.PropertyField(includeIndexHtml); domainList.DoLayoutList(); // Draw the import stuff EditorGUILayout.Space(); UnityEngine.Object testAsset = null; testAsset = EditorGUILayout.ObjectField("Import Domain List", testAsset, typeof(UnityEngine.Object), false); if (testAsset != null) { AssetBundle bundle = null; try { // Load the bundle, and convert it to a domain list bundle = AssetBundle.LoadFromFile(AssetDatabase.GetAssetPath(testAsset)); DomainList domainList = DomainList.Get(bundle); // Decrypt the domain list HostArchiveSetting setting = ((HostArchiveSetting)target); setting.AcceptedDomains = DomainList.Decrypt(domainList, setting.DomainEncrypter); } finally { if (bundle != null) { // Clean-up bundle.Unload(true); } } } } } }
void DrawModuleEditors() { // Note: this will almost definitely need rewriting once new cave gen types are implemented - we're taking // advantage of the fact that both current types make use of both a map gen module and a floor heightmap module. EditorHelpers.DrawLine(); DrawModuleEditor(MAP_GEN_MODULE_LABEL, MAP_GEN_NAME, ref drawMapGenEditor, ref mapGenEditor); EditorHelpers.DrawLine(); DrawModuleEditor(FLOOR_HEIGHTMAP_LABEL, FLOOR_HEIGHTMAP_NAME, ref drawFloorHeightMapEditor, ref floorHeightMapEditor); EditorHelpers.DrawLine(); if (caveGenType == CaveGeneratorUI.CaveGeneratorType.ThreeTiered) { DrawModuleEditor(CEILING_HEIGHTMAP_LABEL, CEILING_HEIGHTMAP_NAME, ref drawCeilingHeightMapEditor, ref ceilingHeightMapEditor); EditorHelpers.DrawLine(); } if (caveGenType == CaveGeneratorUI.CaveGeneratorType.RockOutline) { DrawModuleEditor(OUTLINE_MODULE_LABEL, OUTLINE_NAME, ref drawOutlineEditor, ref outlineEditor); EditorHelpers.DrawLine(); } }
private void newFromArchiveToolStripMenuItem_Click(object sender, EventArgs e) { string[] filePaths = EditorHelpers.ShowOpenFileDialog("Wind Waker Archives (*.arc; *.rarc)|*.arc; *.rarc|All Files (*.*)|*.*", true); //A canceled OFD returns an empty array. if (filePaths.Length == 0) { return; } //A canceled CWDRFA returns an empty string string workDir = CreateWorkingDirFromArchive(filePaths); if (workDir == string.Empty) { return; } OpenFileFromWorkingDir(workDir); }
public override void OnInspectorGUI() { var body = target as Rigidbody; foldout = EditorGUILayout.Foldout(foldout, "Copy & Paste"); if (foldout) { EditorGUILayout.BeginHorizontal("Box"); body = EditorHelpers.CopyPastObjectButtons(body) as Rigidbody; EditorGUILayout.EndHorizontal(); } DrawDefaultInspector(); EditorGUILayout.Space(); EditorHelpers.Label("Changing the Velocity may cause issues."); EditorGUILayout.Space(); body.velocity = EditorHelpers.DrawVector3("Velocity", body.velocity, Vector3.zero, this, false); body.angularVelocity = EditorHelpers.DrawVector3("Angular", body.angularVelocity, Vector3.zero, this, false); }
private Rect DrawHelpBox(Rect rect) { // Check whether to show the help box if (string.IsNullOrEmpty(Message) == false) { // Add indentation rect.x += IndentLeft; rect.width -= IndentLeft; // Draw a header message rect.y += EditorHelpers.VerticalMargin + rect.height; rect.height = EditorHelpers.GetHelpBoxHeight(Message, rect.width); EditorGUI.HelpBox(rect, Message, MessageType); // Remove indentation rect.x -= IndentLeft; rect.width += IndentLeft; } return(rect); }
private void OnEnable() { // Serialized properties and graphical wrappers supportedLanguages = serializedObject.FindProperty("supportedLanguages"); defaultToWhenKeyNotFound = serializedObject.FindProperty("defaultToWhenKeyNotFound"); presetMessageWhenKeyNotFound = serializedObject.FindProperty("presetMessageWhenKeyNotFound"); defaultToWhenTranslationNotFound = serializedObject.FindProperty("defaultToWhenTranslationNotFound"); presetMessageWhenTranslationNotFound = serializedObject.FindProperty("presetMessageWhenTranslationNotFound"); defaultLanguageWhenTranslationNotFound = serializedObject.FindProperty("defaultLanguageWhenTranslationNotFound"); replaceEmptyStringWithDefaultText = serializedObject.FindProperty("replaceEmptyStringWithDefaultText"); // Setup animations EditorHelpers.CreateBool(this, ref showErrorMessage); EditorHelpers.CreateBool(this, ref showDefaultConfigurations); EditorHelpers.CreateBool(this, ref showPresetMessageForKeyNotFound); EditorHelpers.CreateBool(this, ref showDefaultLanguageForTranslationNotFound); EditorHelpers.CreateBool(this, ref showPresetMessageForTranslationNotFound); // Setup transations list translations = serializedObject.FindProperty("translations"); translationsList = new ReorderableList(serializedObject, translations, true, true, true, true); translationsList.drawHeaderCallback = DrawTranslationsListHeader; translationsList.drawElementCallback = DrawTranslationsListElement; translationsList.elementHeightCallback = CalculateTranslationsListElementHeight; translationsList.onAddCallback = OnAddTranslation; translationsList.onRemoveCallback = OnRemoveTranslation; translationsList.onReorderCallbackWithDetails = OnReorderTranslationList; // Populate the status list translationStatus.Clear(); frequencyInKeyAppearance.Clear(); for (int index = 0; index < translationsList.count; ++index) { AddEntryFromTranslationListStatus(translationsList, index); } UpdateTranslationListStatus(translationsList, 0); // Setup search field //searchField = new SearchField(); recalculateSearchResult = true; }
/// <summary> /// Show a dropwdown for our event handlers /// </summary> private void RenderEventListenerDropdown() { GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("EventHandler:", GUILayout.Width(100)); // Get a list of event listeners that are of the given type List <MonoBehaviour> usableListeners = _eventHandlers .Where(eh => ReflectionHelpers.GetGenericArgumentTypes(eh.GetType(), typeof(IEventListener <>))[0].AssemblyQualifiedName == _eventListenerPropertyType.stringValue) .ToList(); // Now that we have our list of EventHandlers, create a list of names that we'll use in our dropdown string helpMessage = (usableListeners.Count > 0) ? "Select an event handler..." : "Please add an event handler to the scene"; List <string> listenersInScene = new List <string>() { helpMessage }; listenersInScene.AddRange(usableListeners.Select(a => EditorHelpers.GetNameForDropdown(a))); // Save the current event handler so we know if we change it UnityEngine.Object lastEventHandler = _eventListener.objectReferenceValue; // Is an EventHandler already selected? // If so, show that in the dropdown int startIndex = 0; if (_eventListener.objectReferenceValue != null) { startIndex = usableListeners.IndexOf((MonoBehaviour)_eventListener.objectReferenceValue) + 1; } // Show the dropdown and get the index the user selects int selectedIndex = EditorGUILayout.Popup(startIndex, listenersInScene.ToArray()); // If the user selects an EventHandler (not the help message) save it on our script if (selectedIndex > 0) { _eventListener.objectReferenceValue = usableListeners[selectedIndex - 1]; } } GUILayout.EndHorizontal(); }
void Save() { bool canSave = true; string notificationMsg = string.Empty; // check if names are valid foreach (var d in EditorHelpers.allEvents) { if (d.id.Contains("New Event") || d.id.Contains("Clone") || d.id.Length == 0) { canSave = false; notificationMsg = "Event (" + d.id + ") has invalid name!\n"; break; } else if (d.startTime.Year < 2016 || d.endTime.Year < 2016) { canSave = false; notificationMsg = "Event (" + d.id + ") has invalid start/end times!\n"; break; } } if (!canSave) { ShowNotification(new GUIContent(notificationMsg + "\nConfig is not saved!")); } else { if (EditorHelpers.allEvents.Count > 0) { EditorHelpers.gameDB.DeleteAllConfigs(EditorHelpers.allEvents[0].GetTableName()); } foreach (var e in EditorHelpers.allEvents) { EditorHelpers.gameDB.SaveConfig(e.GetTableName(), e.id, LitJson.JsonMapper.ToJson(e)); } EditorHelpers.gameDB.IncrementLocalDBVersion(); EditorHelpers.InitEventNames(); dirty = false; } }