public override void OnInspectorGUI() { profile = (TSSProfile)target; serializedProfile = new SerializedObject(profile); serializedProfile.Update(); evulate = EditorGUILayout.Slider(evulate, 0, 1); TSSTweenEditor.DrawTweensPanel(profile.tweens, profile, foldOutTweens, profile.values); DrawItemsPanel(TSSBehaviour.GetItems().Where(i => i.profile == profile).OrderBy(i => i.name).ToArray()); DrawValuesPanel(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
private void DrawItemsPanel(TSSItem[] items) { GUILayout.Space(3); EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); foldOutItems.target = EditorGUILayout.Foldout(foldOutItems.target, " Items (" + items.Length + ")", true, GUI.skin.label); EditorGUILayout.EndHorizontal(); if (foldOutItems.faded > 0) { EditorGUILayout.BeginFadeGroup(foldOutItems.faded); if (items.Length == 0) { EditorGUILayout.HelpBox(hlpBoxMessageNoItems.text, MessageType.Info); } else { for (int i = 0; i < items.Length; i++) { DrawItem(items[i]); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(applyAllProfileButton, TSSEditorUtils.fixedLineHeight)) { if (EditorUtility.DisplayDialog(confirmApplyAllTitle.text, string.Format(confirmApplyAllMessage.text, profile.name), "Yes", "No")) { for (int i = 0; i < items.Length; i++) { Undo.RecordObject(items[i], "[TSS Profile] applying profile"); TSSProfile.ProfileRevert(items[i], profile); } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndVertical(); }
public void LoadListGroupPrep() { ControllerLoadMap _thisListPrep = this.GetComponent <ControllerLoadMap>(); _thisListPrep._listPrep.Clear(); _listGroupPrep.Clear(); GameObject[] currArray = GameObject.FindGameObjectsWithTag("GroupListPrep"); _listProfile = Resources.LoadAll <TSSProfile>(@"TSSProfile\ListPrep"); int i = 0; foreach (GameObject item in currArray) { _listGroupPrep.Add(item.transform.GetChild(0).GetComponent <TSSItem>()); _listGroupPrep[i].profile = _listProfile[i]; TSSProfile.ProfileRevert(_listGroupPrep[i], _listProfile[i]); _thisListPrep._listPrep.Add(item.transform.GetComponent <CreatorGroupListPrep>()); i++; } }
public void OnEnable() { profile = (TSSProfile)target; EditorUtility.SetDirty(profile); if (foldOutValues == null) { foldOutValues = new AnimBool(false); } foldOutValues.valueChanged.AddListener(Repaint); if (foldOutItems == null) { foldOutItems = new AnimBool(false); } foldOutItems.valueChanged.AddListener(Repaint); if (foldOutTweens == null) { foldOutTweens = new AnimBool(false); } foldOutTweens.valueChanged.AddListener(Repaint); }
private void DrawItem(TSSItem item) { GUI.backgroundColor = new Color(0f, 0f, 0f, 0.5f); EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); GUI.backgroundColor = Color.white; EditorGUILayout.ObjectField(item, typeof(TSSItem), true); if (GUILayout.Button(applyProfileButton, TSSEditorUtils.fixedLineHeight)) { Undo.RecordObject(item, "[TSS Profile] applying profile"); TSSProfile.ProfileRevert(item, item.profile); } if (GUILayout.Button(revertProfileButton, TSSEditorUtils.fixedLineHeight)) { if (EditorUtility.DisplayDialog(confirmRevertTitle.text, string.Format(confirmRevertMessage.text, item.name), "Yes", "No")) { Undo.RecordObject(item.profile, "[TSS Profile] reverting profile"); TSSProfile.ProfileApply(item, item.profile); } } EditorGUILayout.EndHorizontal(); }
public static void DrawItemProperty(TSSItem item, string propertyName, string displayPropertyName = null, GUILayoutOption displayPropertyOption = null, bool shortCheckBox = false, bool alternative = false) { GUI.color = Color.white; GUI.backgroundColor = Color.white; if (!ItemPropertyIsValid(propertyName)) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox(string.Format(invalidPropertyName.text, propertyName), MessageType.Warning); EditorGUILayout.EndHorizontal(); return; } if (string.IsNullOrEmpty(displayPropertyName)) { displayPropertyName = propertyName; } if (displayPropertyOption == null) { displayPropertyOption = TSSEditorUtils.max100pxWidth; } Type propertyType = GetItemPropertyType(propertyName); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(TSSText.GetHumanReadableString(displayPropertyName), displayPropertyOption); if (propertyType == typeof(float)) { float displayedValue = GetItemValue <float>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <float>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } float enteredValue = Mathf.Clamp(EditorGUILayout.FloatField(displayedValue), 0, float.MaxValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(bool)) { bool displayedValue = GetItemValue <bool>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <bool>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } bool enteredValue = EditorGUILayout.Toggle(displayedValue, shortCheckBox ? TSSEditorUtils.max18pxWidth : TSSEditorUtils.max120pxWidth); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(string)) { string displayedValue = GetItemValue <string>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <string>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } string enteredValue = EditorGUILayout.TextField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(int)) { int displayedValue = GetItemValue <int>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <int>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } int enteredValue = EditorGUILayout.IntField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(ChainDirection)) { ChainDirection displayedValue = GetItemValue <ChainDirection>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ChainDirection>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ChainDirection enteredValue = (ChainDirection)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(RotationMode)) { RotationMode displayedValue = GetItemValue <RotationMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <RotationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } RotationMode enteredValue = (RotationMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(MaterialMode)) { MaterialMode displayedValue = GetItemValue <MaterialMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <MaterialMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } MaterialMode enteredValue = (MaterialMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(AnimationCurve)) { AnimationCurve displayedValue = GetItemValue <AnimationCurve>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <AnimationCurve>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } AnimationCurve enteredValue = (AnimationCurve)EditorGUILayout.CurveField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(TSSProfile)) { TSSProfile displayedValue = GetItemValue <TSSProfile>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <TSSProfile>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } TSSProfile enteredValue = (TSSProfile)EditorGUILayout.ObjectField(displayedValue, typeof(TSSProfile), false); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); if (enteredValue != null && EditorUtility.DisplayDialog(confirmRevertTitle.text, string.Format(confirmRevertMessage.text, item.profile.name), "Yes", "No")) { TSSProfile.ProfileRevert(item, item.profile); } } } else if (propertyType == typeof(ActivationMode)) { if (alternative) { ItemLoopModePattern displayedValue = ActivationModeToLoopPattern(GetItemValue <ActivationMode>(item, propertyName)); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ItemLoopModePattern enteredValue = (ItemLoopModePattern)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, LoopPatternToActivationMode(enteredValue)); } } else { ActivationMode displayedValue = GetItemValue <ActivationMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ActivationMode enteredValue = (ActivationMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } } else if (propertyType == typeof(ButtonDirection)) { ButtonDirection displayedValue = GetItemValue <ButtonDirection>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ButtonDirection>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ButtonDirection enteredValue = (ButtonDirection)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(ItemUpdateType)) { ItemUpdateType displayedValue = GetItemValue <ItemUpdateType>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ItemUpdateType>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ItemUpdateType enteredValue = (ItemUpdateType)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(PathNormal)) { PathNormal displayedValue = GetItemValue <PathNormal>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <PathNormal>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } PathNormal enteredValue = (PathNormal)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } EditorGUILayout.EndHorizontal(); EditorGUI.showMixedValue = false; }
private void DrawAdvancedPanel() { GUILayout.Space(3); EditorGUILayout.BeginVertical(GUI.skin.box); foldOutAdvanced.target = EditorGUILayout.Foldout(foldOutAdvanced.target, " Advanced", true, GUI.skin.label); if (foldOutAdvanced.faded > 0) { EditorGUILayout.BeginFadeGroup(foldOutAdvanced.faded); GUILayout.Space(3); GUI.backgroundColor = new Color(0f, 0f, 0f, 0.5f); EditorGUILayout.BeginVertical(EditorStyles.helpBox); GUI.backgroundColor = Color.white; bool profilePropertyIdentical = ValuesIsIdentical(GetSelectedItemsValues <TSSProfile>("profile")); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "profile"); if (item.profile == null && profilePropertyIdentical && GUILayout.Button(TSSEditorUtils.addKeyButtonContent, TSSEditorUtils.max18pxWidth)) { item.profile = TSSProfileEditor.CreateProfileAsset(); TSSProfile.ProfileApply(item, item.profile); Selection.SetActiveObjectWithContext(item.gameObject, item); } if (item.profile != null && profilePropertyIdentical && GUILayout.Button(TSSEditorUtils.delKeyButtonContent, TSSEditorUtils.max18pxWidth)) { item.profile = null; } EditorGUILayout.EndHorizontal(); if (item.profile != null && profilePropertyIdentical) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(applyProfileButton)) { Undo.RecordObject(item.profile, "[TSS Item] applying profile"); TSSProfile.ProfileApply(item, item.profile); } if (GUILayout.Button(revertProfileButton)) { foreach (Transform itemTransform in Selection.transforms) { TSSItem item = itemTransform.GetComponent <TSSItem>(); if (item == null) { continue; } Undo.RecordObject(item, "[TSS Item] revert profile"); TSSProfile.ProfileRevert(item, item.profile); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "activationOpen"); DrawItemProperty(item, "activationClose"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "activationStart"); EditorGUILayout.BeginVertical(); DrawItemProperty(item, "loops"); if (item.loops != 0 && ValuesIsIdentical(GetSelectedItemsValues <int>("loops"))) { DrawItemProperty(item, "loopMode", null, null, false, true); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "ignoreChilds"); DrawItemProperty(item, "ignoreParent"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "rotationMode"); DrawItemProperty(item, "materialMode"); EditorGUILayout.EndHorizontal(); if (ValuesIsIdentical(GetSelectedItemsValues <RotationMode>("rotationMode")) && item.rotationMode == RotationMode.path) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(rotationMaskContent, GUILayout.MaxWidth(98)); DrawItemProperty(item, "rotationMaskX", "X", TSSEditorUtils.max18pxWidth); DrawItemProperty(item, "rotationMaskY", "Y", TSSEditorUtils.max18pxWidth); DrawItemProperty(item, "rotationMaskZ", "Z", TSSEditorUtils.max18pxWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "pathNormal"); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "interactions"); DrawItemProperty(item, "blockRaycasting"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); DrawItemProperty(item, "soundControl"); if (item.soundControl && ValuesIsIdentical(GetSelectedItemsValues <bool>("soundControl"))) { DrawItemProperty(item, "soundRestart"); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); DrawItemProperty(item, "videoControl"); if (item.videoControl && ValuesIsIdentical(GetSelectedItemsValues <bool>("videoControl"))) { DrawItemProperty(item, "videoRestart"); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (item.text != null) { TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "randomWave"); string floatFormat = item.floatFormat; DrawItemProperty(item, "floatFormat"); if (floatFormat != item.floatFormat) { try { 0f.ToString(item.floatFormat); } catch { Debug.LogWarningFormat("TSS Item \"{0}({1})\" has uncorrect float format!", item.name, item.GetInstanceID()); item.floatFormat = floatFormat; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } if (item.button != null || (item.parent != null && item.parent.button != null && item.tweens.Where(t => t.enabled && t.direction == TweenDirection.Button).ToArray().Length > 0)) { TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "buttonDuration"); DrawItemProperty(item, "buttonDirection"); EditorGUILayout.EndHorizontal(); if (item.button != null && Selection.transforms.Length == 1) { TSSEditorUtils.DrawKeyCodeListProperty(item.values.onKeyboard, item, serializedItem.FindProperty("values").FindPropertyRelative("onKeyboard"), false); } EditorGUILayout.EndVertical(); } TSSEditorUtils.BeginBlackVertical(); EditorGUILayout.BeginHorizontal(); DrawItemProperty(item, "updatingType"); DrawItemProperty(item, "timeScaled", null, GUILayout.MaxWidth(80), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndVertical(); }
IEnumerator LoadContent() { GameObject emptyGO = new GameObject(); string pathToFolder = Path.Combine(Application.streamingAssetsPath, _pathFromStreamingFolder); string[] dirs = Directory.GetDirectories(pathToFolder); string pathToFile = Path.Combine(dirs[0], "size.txt"); if (!File.Exists(pathToFile)) { Debug.LogError("Size file not found!!!"); } string[] vextorSize = File.ReadAllLines(pathToFile); float.TryParse(vextorSize[0], out _sizeImage.x); float.TryParse(vextorSize[1], out _sizeImage.y); int.TryParse(vextorSize[2], out _countArrayWidth); int.TryParse(vextorSize[3], out _countArrayHeight); _groupMinimap.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x); _groupMinimap.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y); RectTransform container = _contentTransform.GetComponent <RectTransform>(); container.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x); container.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y); TSSCore core = GetComponent <TSSCore>(); _directAlphaProfile = Resources.Load <TSSProfile>("DirectAlpha"); bool lastFlag; for (int j = 0; j < dirs.Length; j++) { functionLoadForAttach(dirs[j]); List <string> currentListImage = _attachFiles; int currentArrayWidth = 0, currentArrayHeight = 0; lastFlag = j == dirs.Length - 1 ? true : false; GameObject groupObject = Instantiate(emptyGO, _contentTransform.transform); groupObject.name = j == 0 ? "Map" : groupObject.name = "Prep_" + j.ToString("00"); groupObject.AddComponent <RectTransform>(); groupObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _sizeImage.x); groupObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _sizeImage.y); if (j == 0) { TSSItem newStateObject = new TSSItem(); TSSState stateState = core.AddState(newStateObject, (j).ToString()); stateState.AddSelectionKey((KeyCode)((int)KeyCode.Alpha0)); } else { groupObject.AddComponent <CanvasGroup>(); TSSItem newStateObject = groupObject.AddComponent <TSSItem>(); TSSState stateState = core.AddState(newStateObject, (j).ToString()); stateState.AddSelectionKey((KeyCode)((int)KeyCode.Alpha1 + j - 1)); newStateObject.profile = _directAlphaProfile; TSSProfile.ProfileRevert(newStateObject, _directAlphaProfile); } foreach (var element in currentListImage) { using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(element)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); } else { var texture = DownloadHandlerTexture.GetContent(uwr); texture.Compress(true); texture.Apply(false, true); GameObject _currentMapElement = Instantiate(_prefabElementMap, groupObject.transform); _currentMapElement.GetComponent <RawImage>().texture = texture; _currentMapElement.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, texture.width); _currentMapElement.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, texture.height); _currentMapElement.GetComponent <RectTransform>().anchoredPosition = new Vector2(currentArrayWidth * 8000, currentArrayHeight * -8000); currentArrayWidth++; if (currentArrayWidth >= _countArrayWidth) { currentArrayHeight++; currentArrayWidth = 0; } } uwr.Dispose(); yield return(new WaitForSeconds(0.1f)); } } if (lastFlag) { CreateMinimap(); } } core.useEvents = true; TSS.Base.TSSBehaviour.RefreshAndStart(); Destroy(emptyGO); _flagLoad = true; }