public void UpdateInfoValues(bool _isLeftSide, string[] _values) { UIElementsGroup curElement = _isLeftSide ? leftSide : rightSide; for (int i = 0; i < _values.Length; ++i) { curElement.groupTextList[i].text = _values[i]; } }
public void UpdateInfoValues(bool _isLeftSide, string _name, string _lastName, string _value1, string _value2, string _value3) { UIElementsGroup curElement = _isLeftSide ? leftSide : rightSide; curElement.groupTextList [0].text = _name; curElement.groupTextList [1].text = _lastName; curElement.groupTextList [2].text = _value1; curElement.groupTextList [3].text = _value2; curElement.groupTextList [4].text = _value3; }
private void CrossFadeGroup(UIElementsGroup _group, float _imageAlphaValue, float _textAlphaValue, float _fadeTime) { foreach (Image curImage in _group.groupImagesList) { if (_imageAlphaValue > 0.5f) { curImage.canvasRenderer.SetAlpha(0.0f); } curImage.CrossFadeAlpha(_imageAlphaValue, _fadeTime, true); } foreach (Text curText in _group.groupTextList) { if (_textAlphaValue > 0.5f) { curText.canvasRenderer.SetAlpha(0.0f); } curText.CrossFadeAlpha(_textAlphaValue, _fadeTime, true); } }
public override void OnInspectorGUI() { serializedObject.Update(); bool usedActivationControl = false; for (int i = 0; i < targets.Length; i++) { UIElement element = targets[i] as UIElement; if (element.UseSimpleActivation) { usedActivationControl = true; } } EditorGUILayout.Space(); #region Settings EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); bool someoneControlled = false; for (int i = 0; i < targets.Length; i++) { UIElement e = (UIElement)targets[i]; if (e.ControlledBy != null) { someoneControlled = true; } } string controllerName = "NONE"; //if we are only selecting one object and there's someone controlled in the selection array, then it is this object. if (targets.Length == 1 && someoneControlled) { controllerName = controlledBy.objectReferenceValue.name; } else if (targets.Length > 1 && someoneControlled) { controllerName = "-"; } #region Controlled By EditorGUILayout.LabelField("Controlled By: ", controllerName); if (someoneControlled && GUILayout.Button("Remove Control")) { for (int i = 0; i < targets.Length; i++) { UIElement e = (UIElement)targets[i]; Undo.RecordObject(e, "Remove Control"); Menu m = e.ControlledBy as Menu; if (m != null) { Undo.RecordObject(m, "Remove Control"); m.AnimatedElements.Remove((UIElement)targets[i]); } else { UIElementsGroup eg = e.ControlledBy as UIElementsGroup; if (eg != null) { Undo.RecordObject(eg, "Remove Control"); eg.AnimatedElements.Remove((UIElement)targets[i]); } else { SideMenu sm = e.ControlledBy as SideMenu; if (sm != null) { Undo.RecordObject(sm, "Remove Control"); sm.AnimatedElements.Remove((UIElement)targets[i]); } else { Popup p = e.ControlledBy as Popup; if (p != null) { Undo.RecordObject(p, "Remove Control"); p.AnimatedElements.Remove((UIElement)targets[i]); } } } } e.ControlledBy = null; } } #endregion EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Is Visible?", visible.boolValue.ToString()); EditorGUILayout.PropertyField(menuDependant); if (!menuDependant.boolValue) { EditorGUILayout.PropertyField(visible); EditorGUILayout.PropertyField(prewarm); } EditorGUILayout.PropertyField(useUnscaledTime); EditorGUILayout.PropertyField(deactivateWhileInvisible); #endregion if (!usedActivationControl) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel); selectedAnimTab = GUILayout.Toolbar(selectedAnimTab, new string[] { "Hiding", "Showing" }); if (selectedAnimTab != lastAnimSection) { GUI.FocusControl(""); lastAnimSection = selectedAnimTab; } bool hidingTab = selectedAnimTab == 0; #region Animation Sections if (hidingTab) { EditorGUILayout.PropertyField(hideAfter); EditorGUILayout.PropertyField(hidingDuration); } else { EditorGUILayout.PropertyField(showAfter); #region Showing Duration EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(durationLink.boolValue); if (durationLink.boolValue) { showingDuration.floatValue = hidingDuration.floatValue; } EditorGUILayout.PropertyField(showingDuration); EditorGUI.EndDisabledGroup(); durationLink.boolValue = GUILayout.Toggle(durationLink.boolValue, new GUIContent(linkIcon, "Toggle hiding duration link."), EditorStyles.miniButton, GUILayout.Width(25)); if (lastDurationLink != durationLink.boolValue) { GUI.FocusControl(""); lastDurationLink = durationLink.boolValue; } EditorGUILayout.EndHorizontal(); #endregion } EditorGUILayout.Space(); //Movement DrawAnimationSection(movementSection, hidingTab, ref movementFoldout, ref showMovementProps); EditorGUILayout.Space(); //Rotation DrawAnimationSection(rotationSection, hidingTab, ref rotationFoldout, ref showRotationProps); EditorGUILayout.Space(); //Scale DrawAnimationSection(scaleSection, hidingTab, ref scaleFoldout, ref showScaleProps); EditorGUILayout.Space(); //Opacity DrawAnimationSection(opacitySection, hidingTab, ref opacityFoldout, ref showOpacityProps); EditorGUILayout.Space(); //Slice DrawAnimationSection(sliceSection, hidingTab, ref sliceFoldout, ref showSliceProps); #endregion GUILayout.Space(10); EditorGUILayout.LabelField("* Shared settings between both tabs.", EditorStyles.miniLabel); #region Separator EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("__________________"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); #endregion } else { EditorGUILayout.Space(); EditorGUILayout.HelpBox("No animation controls available. This GameObject is being controlled by \"Simple Activate/Deactivate\" option.", MessageType.Info); } #region Activation EditorGUILayout.LabelField("Simple Activate/Deactivate", EditorStyles.boldLabel); EditorGUILayout.PropertyField(useSimpleActivation, new GUIContent("Use Activation Control")); #endregion EditorGUILayout.Space(); #region Sounds and Events EditorGUILayout.LabelField("Sounds & Events", EditorStyles.boldLabel); EditorGUILayout.PropertyField(showingClip, new GUIContent("Showing Clip")); EditorGUILayout.PropertyField(hidingClip, new GUIContent("Hiding Clip")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(onShow, new GUIContent("On Show")); EditorGUILayout.PropertyField(onHide, new GUIContent("On Hide")); EditorGUILayout.PropertyField(onShowComplete, new GUIContent("On Show Complete")); EditorGUILayout.PropertyField(onHideComplete, new GUIContent("On Hide Complete")); EditorGUILayout.PropertyField(ignoreEventsOnInitialization, new GUIContent("Ignore On Initialization")); #endregion EditorGUILayout.Space(); EditorPrefs.SetBool("movementFoldout", movementFoldout); EditorPrefs.SetBool("rotationFoldout", rotationFoldout); EditorPrefs.SetBool("scaleFoldout", scaleFoldout); EditorPrefs.SetBool("opacityFoldout", opacityFoldout); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { UIElementsGroup myElementsGroup = target as UIElementsGroup; #region User Interface EditorGUILayout.Space(); EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel); EditorGUILayout.PropertyField(visible); EditorGUILayout.PropertyField(prewarm); EditorGUILayout.PropertyField(deactivateWhileInvisible); EditorGUILayout.Space(); EditorGUILayout.LabelField("Elements", EditorStyles.boldLabel); EditorGUILayout.PropertyField(animatedElements, true); EditorGUILayout.Space(); EditorGUILayout.LabelField("Switching", EditorStyles.boldLabel); if (useSimpleActivation.boolValue == true) { EditorGUILayout.HelpBox("No animations will be played, all the animated elements will be ignored because \"Use Simple Activation\" option is set to true.", MessageType.Info); } EditorGUILayout.PropertyField(useSimpleActivation); EditorGUILayout.Space(); EditorGUILayout.LabelField("Sounds & Events", EditorStyles.boldLabel); EditorGUILayout.PropertyField(showingClip); EditorGUILayout.PropertyField(hidingClip); EditorGUILayout.Space(); EditorGUILayout.PropertyField(onShow); EditorGUILayout.PropertyField(onHide); EditorGUILayout.PropertyField(onShowComplete); EditorGUILayout.PropertyField(onHideComplete); EditorGUILayout.PropertyField(ignoreEventsOnInitialization, new GUIContent("Ignore On Initialization")); EditorGUILayout.Space(); #endregion #region Tools EditorGUILayout.LabelField("Tools", EditorStyles.boldLabel); #region Update Animated Elements Button if (GUILayout.Button("Update Animated Elements", GUILayout.Height(30))) { //Save old elements list to make a check after updating. List <UIElement> oldElements = myElementsGroup.AnimatedElements; added = 0; removed = 0; Undo.RecordObject(myElementsGroup, "Update Animated Items"); myElementsGroup.AnimatedElements = GetAnimatedElements(myElementsGroup.transform); UIElement freeMenuUE = myElementsGroup.GetComponent <UIElement>(); if (freeMenuUE) { myElementsGroup.AnimatedElements.Insert(0, freeMenuUE); } //Check which elements are added and which elements are removed. for (int i = 0; i < myElementsGroup.AnimatedElements.Count; i++) { Undo.RecordObject(myElementsGroup.AnimatedElements[i], "Update Animated Items"); if (!oldElements.Contains(myElementsGroup.AnimatedElements[i])) { added++; } } removed = oldElements.Count - myElementsGroup.AnimatedElements.Count + added; updatedElements = true; } #endregion #region Elements Updated Info if (updatedElements) { string removedText = removed != 0 ? "Removed " + removed + " element" + (removed == 1 ? "." : "s.") : ""; string addedText = added != 0 ? "Added " + added + " element" + (added == 1 ? ". " : "s. ") : ""; string finalText = (added != 0 || removed != 0) ? addedText + removedText : "Nothing changed. Is the element you want this holder to control being controlled by another holder?"; EditorGUILayout.HelpBox(finalText, (added != 0 || removed != 0) ? MessageType.Info : MessageType.Warning); } #endregion #region Check Menu Independant Elements if (myElementsGroup.AnimatedElements != null) { for (int i = 0; i < myElementsGroup.AnimatedElements.Count; i++) { if (myElementsGroup.AnimatedElements[i] == null) { continue; } if (!myElementsGroup.AnimatedElements[i].MenuDependent) { if (EditorUtility.DisplayDialog("Error", myElementsGroup.AnimatedElements[i].gameObject.name + " is menu independant but is inside this Element Group's elements list.", "Remove it from the list", "Switch it to menu dependant")) { Undo.RecordObject(myElementsGroup, "Removing from list"); myElementsGroup.AnimatedElements[i].ControlledBy = null; myElementsGroup.AnimatedElements.RemoveAt(i); i--; continue; } else { Undo.RecordObject(myElementsGroup, "Switch to menu dependant"); myElementsGroup.AnimatedElements[i].MenuDependent = true; } } if (myElementsGroup.AnimatedElements[i].ControlledBy != myElementsGroup) { myElementsGroup.AnimatedElements[i].ControlledBy = myElementsGroup; } } } #endregion #endregion serializedObject.ApplyModifiedProperties(); }