public override void OnInspectorGUI() { serializedObject.Update(); var simAsset = (SimAsset)target; bool wasGUI = GUI.enabled; EditorGUILayout.PropertyField(_hasTransform); if (_hasTransform.boolValue) { if (string.IsNullOrEmpty(_guidProp.stringValue)) { EditorGUILayout.HelpBox("Only prefabs can bind a view", MessageType.Info); GUI.enabled = false; } else if (PrefabUtility.IsPartOfNonAssetPrefabInstance(simAsset)) { // disable properties so we cannot add overrides in scenes EditorGUILayout.HelpBox("Open prefab to edit", MessageType.Info); GUI.enabled = false; } EditorGUILayout.PropertyField(_viewTechTypeProp); var viewTechType = (ViewTechType)_viewTechTypeProp.enumValueIndex; if (viewTechType == ViewTechType.GameObject) { EditorGUILayout.PropertyField(_bindedViewPrefabProp, EditorGUIUtilityX.TempContent("View Prefab")); } else if (viewTechType == ViewTechType.Tile) { EditorGUILayout.PropertyField(_bindedViewTileProp, EditorGUIUtilityX.TempContent("View Tile")); } GUI.enabled = wasGUI; if (viewTechType == ViewTechType.GameObject && _bindedViewPrefabProp.objectReferenceValue != null) { EditorGUILayout.PropertyField(_showGhostProp); } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { var castedTarget = (GameActionAuth)target; EditorGUI.BeginChangeCheck(); DrawPrimaryTitle("Simulation"); GUIContent label = EditorGUIUtilityX.TempContent("Game Action Type"); EditorGUILayoutX.SearchablePopupString(_gameActionProp, label, s_availableTypeNames); if (_gameActionProp.stringValue != "") { Type gameActionType = TypeUtility.FindType(_gameActionProp.stringValue, false); if (gameActionType != null) { Type[] settingAuthTypes = GameActionSettingAuthBase.GetRequiredSettingAuthTypes(gameActionType); // Remove extra setting in property list for (int i = _gameActionSettingsProp.arraySize - 1; i >= 0; i--) { if (castedTarget.GameActionSettings[i] == null || !settingAuthTypes.Contains(castedTarget.GameActionSettings[i].GetType())) { _gameActionSettingsProp.DeleteArrayElementAtIndex(i); castedTarget.GameActionSettings.RemoveAt(i); } } // Add missing setting to property list for (int i = 0; i < settingAuthTypes.Length; i++) { Type currentAuthSettingType = settingAuthTypes[i]; if (currentAuthSettingType == null) { continue; } if (!castedTarget.GameActionSettings.Any((x) => x.GetType() == currentAuthSettingType)) { _gameActionSettingsProp.InsertArrayElementAtIndex(_gameActionSettingsProp.arraySize); SerializedProperty currentGameActionSetting = _gameActionSettingsProp.GetArrayElementAtIndex(_gameActionSettingsProp.arraySize - 1); var newAuthSetting = Activator.CreateInstance(currentAuthSettingType); currentGameActionSetting.managedReferenceValue = newAuthSetting; castedTarget.GameActionSettings.Add((GameActionSettingAuthBase)newAuthSetting); } } for (int i = 0; i < _gameActionSettingsProp.arraySize; i++) { EditorGUILayout.PropertyField(_gameActionSettingsProp.GetArrayElementAtIndex(i)); } } } DrawLine(10); DrawPrimaryTitle("Presentation"); EditorGUILayout.PropertyField(_sfxProp); EditorGUILayout.PropertyField(_animationProp); EditorGUILayout.PropertyField(_surveyProp); EditorGUILayout.PropertyField(_instigatorVFXProp); EditorGUILayout.PropertyField(_targetsVFXProp); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }