private void DrawType() { List <ReflectionInfo> cache; Cache.TryGetTarget(out cache); InspectorUtils.DrawDefaultScriptField(serializedObject); EditorGUI.BeginChangeCheck(); { foreach (ReflectionInfo info in cache) { var property = serializedObject.FindProperty(info.Info.Name); if (property != null) { DrawField(info, property); } else { DrawProperty(info); } } } if (EditorGUI.EndChangeCheck()) { (target as IBaseObject)?.OnPostValidate(); } }
public override void OnInspectorGUI() { InspectorUtils.DrawDefaultScriptField(serializedObject); EditorGUI.BeginChangeCheck(); var list = EditorGUILayout.ObjectField(Target.Prefabs, typeof(PrefabRandomizerList), true, GUILayout.ExpandWidth(true)) as PrefabRandomizerList; if (EditorGUI.EndChangeCheck()) { foreach (PrefabRandomizer rand in targets.Select(r => r as PrefabRandomizer)) { if (rand) { rand.Prefabs = list; } } } GUILayout.BeginHorizontal(); { if (GUILayout.Button("Randomize")) { if (targets.Length == 0 || targets.Length == 1) { Undo.RegisterCompleteObjectUndo(Target, "Randomize Prefab"); Target.Randomize(true); } else { foreach (PrefabRandomizer obj in targets.Select(a => a as PrefabRandomizer)) { obj?.Randomize(true); } } } Target.Locked = GUILayout.Toggle(Target.Locked, Target.Locked ? "Unlock Prefab" : "Lock Prefab"); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); }
public override void OnInspectorGUI() { InspectorUtils.DrawDefaultScriptField(serializedObject); serializedObject.Update(); { HandleField(ref Dialog.Dialog, "Dialog Script"); InspectorUtils.DrawFoldableProperty(serializedObject.FindProperty("OnDialogStart")); InspectorUtils.DrawFoldableProperty(serializedObject.FindProperty("OnDialogEnd")); var actors = serializedObject.FindProperty("Actors"); if (actors.arraySize != 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Actors", EditorStyles.boldLabel); for (int i = 0; i < actors.arraySize; i++) { EditorGUILayout.PropertyField(actors.GetArrayElementAtIndex(i)); } } var functions = serializedObject.FindProperty("Functions"); if (functions.arraySize != 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Functions", EditorStyles.boldLabel); for (int i = 0; i < functions.arraySize; i++) { var prop = functions.GetArrayElementAtIndex(i); InspectorUtils.DrawFoldableProperty(prop, prop.FindPropertyRelative("Name").stringValue); } } } serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); if (GUILayout.Button("Reload")) { Dialog.ReloadDialog(); } }
private void DrawType() { List <ReflectionInfo> cache; Cache.TryGetTarget(out cache); InspectorUtils.DrawDefaultScriptField(serializedObject); foreach (ReflectionInfo info in cache) { var property = serializedObject.FindProperty(info.Info.Name); if (property != null) { DrawField(info, property); } else { DrawProperty(info); } } }
public override void OnInspectorGUI() { if (!Initialize()) { return; } InspectorUtils.DrawDefaultScriptField(serializedObject); GUILayout.Label("Description", EditorStyles.boldLabel); EditorGUILayout.TextArea(Node.Description, EditorStyles.wordWrappedLabel); EditorGUILayout.Space(); GUILayout.Label("Settings", EditorStyles.boldLabel); InspectorUtils.DrawDefaultInspectorWithoutScriptField(serializedObject); EditorGUILayout.Space(); GUILayout.Label("Parameters", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth -= FieldLeftShift; var requiredParameters = Node.GetType().GetProperties().Where(p => System.Attribute.IsDefined(p, typeof(Blackboard.Required))); foreach (PropertyInfo propertyInfo in requiredParameters) { if (!propertyInfo.CanRead || !propertyInfo.CanWrite) { EditorGUILayout.HelpBox(string.Format("Property '{0}' must be both readable and writable", propertyInfo.Name), MessageType.Error); continue; } var typename = KnownType.GetDisplayedName(propertyInfo.PropertyType); if (typename == null) { EditorGUILayout.HelpBox(string.Format("Type {0} is not a known type!", propertyInfo.PropertyType), MessageType.Error); continue; } var matchingParameters = Parameters.Where(p => p.GetHoldType().Type == propertyInfo.PropertyType).ToList(); int oldIndex = -1;//Node.GetGenericParameterIndex(propertyInfo.Name, propertyInfo.PropertyType, matchingParameters); bool wasConstant = Node.IsGenericParameterConstant(propertyInfo.Name); BeginPanelBackground(wasConstant, oldIndex == -1); { GUILayout.BeginHorizontal(); { DrawLabel(propertyInfo.Name); var fieldRect = EditorGUILayout.GetControlRect(true, LockSize, SpaceEditorStyles.LightObjectField); var lockRect = new Rect(fieldRect.x + fieldRect.width - LockSize, fieldRect.y + 2, LockSize, fieldRect.height); bool isConstant = EditorGUI.Toggle(lockRect, wasConstant, SpaceEditorStyles.LockButton); fieldRect.width -= LockSize; if (isConstant) { // Variant parameter = wasConstant // ? Node.ParametrizedProperties[propertyInfo.Name].Parameter // : new Variant(propertyInfo.PropertyType); // // VariantUtils.DrawParameter(fieldRect, parameter, false); // // Node.SetRequiredParameter(propertyInfo.Name, parameter, true); } else { fieldRect.y += 2; /*var paramListContent = BuildParameterGUIList(typename, matchingParameters); * int newIndex = EditorGUI.Popup(fieldRect, GUIContent.none, oldIndex + 1, paramListContent.ToArray(), SpaceEditorStyles.LightObjectField); * * if (!Editor.ExecuteInRuntime() && (oldIndex != (newIndex - 1) || (isConstant != wasConstant))) * { * ProcessSelectionResult(newIndex, propertyInfo, matchingParameters); * }*/ } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }