public override void SceneSettingsGUI() { #if UNITY_EDITOR EditorGUILayout.BeginHorizontal(); KickStarter.sceneSettings.navMesh = (NavigationMesh)EditorGUILayout.ObjectField("Default NavMesh:", KickStarter.sceneSettings.navMesh, typeof(NavigationMesh), true); if (!SceneSettings.IsUnity2D()) { EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("This pathfinding method is only compatible with 'Unity 2D' mode.", MessageType.Warning); EditorGUILayout.BeginHorizontal(); } else if (KickStarter.sceneSettings.navMesh == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { NavigationMesh newNavMesh = null; newNavMesh = SceneManager.AddPrefab("Navigation", "NavMesh2D", true, false, true).GetComponent <NavigationMesh>(); newNavMesh.gameObject.name = "Default NavMesh"; KickStarter.sceneSettings.navMesh = newNavMesh; EditorGUIUtility.PingObject(newNavMesh.gameObject); } } EditorGUILayout.EndHorizontal(); #endif }
private void ArrowGUI(Arrow arrow, string label) { if (arrow != null) { ArrowPrompt _target = (ArrowPrompt)target; arrow.isPresent = EditorGUILayout.Toggle("Provide?", arrow.isPresent); if (arrow.isPresent) { arrow.texture = (Texture2D)EditorGUILayout.ObjectField("Icon texture:", arrow.texture, typeof(Texture2D), true); EditorGUILayout.BeginHorizontal(); arrow.linkedCutscene = (Cutscene)EditorGUILayout.ObjectField("Linked Cutscene:", arrow.linkedCutscene, typeof(Cutscene), true); if (arrow.linkedCutscene == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Auto-create Cutscene"); Cutscene newCutscene = SceneManager.AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>(); newCutscene.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + ": " + label); arrow.linkedCutscene = newCutscene; } } EditorGUILayout.EndHorizontal(); } } }
public override void OnInspectorGUI () { GameCamera25D _target = (GameCamera25D) target; EditorGUILayout.BeginVertical ("Button"); EditorGUILayout.LabelField ("Background image", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal (); _target.backgroundImage = (BackgroundImage) EditorGUILayout.ObjectField ("Prefab:", _target.backgroundImage, typeof (BackgroundImage), true); if (_target.backgroundImage) { if (GUILayout.Button ("Set as active", GUILayout.MaxWidth (90f))) { Undo.RecordObject (_target, "Set active background"); _target.SetActiveBackground (); SnapCameraInEditor (_target); } } else { if (GUILayout.Button ("Create", GUILayout.MaxWidth (90f))) { Undo.RecordObject (_target, "Create Background Image"); BackgroundImage newBackgroundImage = SceneManager.AddPrefab ("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>(); string cameraName = _target.gameObject.name; newBackgroundImage.gameObject.name = AdvGame.UniqueName (cameraName + ": Background"); _target.backgroundImage = newBackgroundImage; } } EditorGUILayout.EndHorizontal (); if (!_target.GetComponent <Camera>().orthographic) { EditorGUILayout.Space (); EditorGUILayout.LabelField ("Perspective offset", EditorStyles.boldLabel); _target.perspectiveOffset.x = EditorGUILayout.Slider ("Horizontal:", _target.perspectiveOffset.x, -0.05f, 0.05f); _target.perspectiveOffset.y = EditorGUILayout.Slider ("Vertical:", _target.perspectiveOffset.y, -0.05f, 0.05f); } EditorGUILayout.EndVertical (); if (_target.isActiveEditor) { UpdateCameraSnap (_target); } UnityVersionHandler.CustomSetDirty (_target); }
public override void OnInspectorGUI() { GameCamera25D _target = (GameCamera25D)target; CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Background image", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); _target.backgroundImage = (BackgroundImage)CustomGUILayout.ObjectField <BackgroundImage> ("Background:", _target.backgroundImage, true, "", "The BackgroundImage to display underneath all scene objects"); if (_target.backgroundImage) { if (!Application.isPlaying && GUILayout.Button("Set as active", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Set active background"); _target.SetActiveBackground(); } } else { if (GUILayout.Button("Create", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Create Background Image"); BackgroundImage newBackgroundImage = SceneManager.AddPrefab("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>(); string cameraName = _target.gameObject.name; newBackgroundImage.gameObject.name = AdvGame.UniqueName(cameraName + ": Background"); _target.backgroundImage = newBackgroundImage; } } EditorGUILayout.EndHorizontal(); if (MainCamera.AllowProjectionShifting(_target.GetComponent <Camera>())) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Perspective offset", EditorStyles.boldLabel); _target.perspectiveOffset.x = CustomGUILayout.Slider("Horizontal:", _target.perspectiveOffset.x, -0.05f, 0.05f, "", "The horizontal offset in perspective from the camera's centre"); _target.perspectiveOffset.y = CustomGUILayout.Slider("Vertical:", _target.perspectiveOffset.y, -0.05f, 0.05f, "", "The vertical offset in perspective from the camera's centre"); } CustomGUILayout.EndVertical(); if (_target.isActiveEditor) { _target.UpdateCameraSnap(); } UnityVersionHandler.CustomSetDirty(_target); }
private static void CreateObjectFromHierarchy(MenuCommand menuCommand, string folderName, string prefabName) { if (KickStarter.sceneSettings == null) { ACDebug.LogWarning("Cannot create " + prefabName + " until Adventure Creator has prepared the scene from the top of the Scene Manager."); return; } GameObject newObject = SceneManager.AddPrefab(folderName, prefabName, true, true, false); GameObjectUtility.SetParentAndAlign(newObject, menuCommand.context as GameObject); Undo.RegisterCreatedObjectUndo(newObject, "Create " + newObject.name); Selection.activeObject = newObject; }
public override void OnInspectorGUI() { GameCamera25D _target = (GameCamera25D)target; EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Background image", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); _target.backgroundImage = (BackgroundImage)EditorGUILayout.ObjectField("Prefab:", _target.backgroundImage, typeof(BackgroundImage), true); if (_target.backgroundImage) { if (GUILayout.Button("Set as active", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Set active background"); _target.SetActiveBackground(); SnapCameraInEditor(_target); } } else { if (GUILayout.Button("Create", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Create Background Image"); BackgroundImage newBackgroundImage = SceneManager.AddPrefab("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>(); string cameraName = _target.gameObject.name; newBackgroundImage.gameObject.name = AdvGame.UniqueName(cameraName + ": Background"); _target.backgroundImage = newBackgroundImage; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (_target.isActiveEditor) { UpdateCameraSnap(_target); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public static Cutscene CutsceneGUI(string label, Cutscene cutscene) { EditorGUILayout.BeginHorizontal(); cutscene = (Cutscene)EditorGUILayout.ObjectField(label, cutscene, typeof(Cutscene), true); if (cutscene == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { cutscene = SceneManager.AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>(); cutscene.Initialise(); } } EditorGUILayout.EndHorizontal(); return(cutscene); }
public static Cutscene CutsceneGUI(string label, Cutscene cutscene, string defaultName = "", string api = "", string tooltip = "") { EditorGUILayout.BeginHorizontal(); cutscene = (Cutscene)CustomGUILayout.ObjectField <Cutscene> (label, cutscene, true, api, tooltip); if (cutscene == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { cutscene = SceneManager.AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>(); cutscene.Initialise(); if (!string.IsNullOrEmpty(defaultName)) { cutscene.gameObject.name = AdvGame.UniqueName(defaultName); } } } EditorGUILayout.EndHorizontal(); return(cutscene); }
public override void OnInspectorGUI() { Moveable_Drag _target = (Moveable_Drag)target; GetReferences(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel); _target.maxSpeed = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed); _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Drag settings:", EditorStyles.boldLabel); _target.dragMode = (DragMode)EditorGUILayout.EnumPopup("Drag mode:", _target.dragMode); if (_target.dragMode == DragMode.LockToTrack) { _target.track = (DragTrack)EditorGUILayout.ObjectField("Track to stick to:", _target.track, typeof(DragTrack), true); _target.setOnStart = EditorGUILayout.Toggle("Set starting position?", _target.setOnStart); if (_target.setOnStart) { _target.trackValueOnStart = EditorGUILayout.Slider("Initial distance along:", _target.trackValueOnStart, 0f, 1f); } EditorGUILayout.BeginHorizontal(); _target.interactionOnMove = (Interaction)EditorGUILayout.ObjectField("Interaction on move:", _target.interactionOnMove, typeof(Interaction), true); if (_target.interactionOnMove == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name); _target.interactionOnMove = newInteraction; } } EditorGUILayout.EndVertical(); } else if (_target.dragMode == DragMode.MoveAlongPlane) { _target.alignMovement = (AlignDragMovement)EditorGUILayout.EnumPopup("Align movement:", _target.alignMovement); if (_target.alignMovement == AlignDragMovement.AlignToPlane) { _target.plane = (Transform)EditorGUILayout.ObjectField("Movement plane:", _target.plane, typeof(Transform), true); } } else if (_target.dragMode == DragMode.RotateOnly) { _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor); _target.allowZooming = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming); if (_target.allowZooming) { _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed); _target.minZoom = EditorGUILayout.FloatField("Closest distance:", _target.minZoom); _target.maxZoom = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom); } } if (_target.dragMode != DragMode.LockToTrack) { _target.noGravityWhenHeld = EditorGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld); } if (Application.isPlaying && _target.dragMode == DragMode.LockToTrack && _target.track) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Distance along: " + _target.GetPositionAlong().ToString(), EditorStyles.miniLabel); } EditorGUILayout.EndVertical(); if (_target.dragMode == DragMode.LockToTrack && _target.track is DragTrack_Hinge) { SharedGUI(_target, true); } else { SharedGUI(_target, false); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public override void OnInspectorGUI() { if (!sideIcon) { sideIcon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D)); } if (AdvGame.GetReferences() == null) { Debug.LogError("A References file is required - please use the Adventure Creator window to create one."); EditorGUILayout.LabelField("No References file found!"); } else { if (AdvGame.GetReferences().inventoryManager) { inventoryManager = AdvGame.GetReferences().inventoryManager; } if (AdvGame.GetReferences().cursorManager) { cursorManager = AdvGame.GetReferences().cursorManager; } if (AdvGame.GetReferences().settingsManager) { settingsManager = AdvGame.GetReferences().settingsManager; } if (_target.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString()); } _target.interactionSource = (InteractionSource)EditorGUILayout.EnumPopup("Interaction source:", _target.interactionSource); _target.hotspotName = EditorGUILayout.TextField("Label (if not name):", _target.hotspotName); _target.highlight = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", _target.highlight, typeof(Highlight), true); EditorGUILayout.BeginHorizontal(); _target.centrePoint = (Transform)EditorGUILayout.ObjectField("Centre point (override):", _target.centrePoint, typeof(Transform), true); if (_target.centrePoint == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Hotspot centre: " + _target.gameObject.name; GameObject go = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false); go.name = prefabName; go.transform.position = _target.transform.position; _target.centrePoint = go.transform; if (GameObject.Find("_Markers")) { go.transform.parent = GameObject.Find("_Markers").transform; } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _target.walkToMarker = (Marker)EditorGUILayout.ObjectField("Walk-to marker:", _target.walkToMarker, typeof(Marker), true); if (_target.walkToMarker == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Marker"; if (settingsManager && settingsManager.IsUnity2D()) { prefabName += "2D"; } Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>(); newMarker.gameObject.name += (": " + _target.gameObject.name); newMarker.transform.position = _target.transform.position; _target.walkToMarker = newMarker; } } EditorGUILayout.EndHorizontal(); _target.drawGizmos = EditorGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos); if (settingsManager != null && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive) { _target.oneClick = EditorGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick); } EditorGUILayout.Space(); UseInteractionGUI(); if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive) { EditorGUILayout.Space(); LookInteractionGUI(); } EditorGUILayout.Space(); InvInteractionGUI(); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public override void OnInspectorGUI() { if (AdvGame.GetReferences() == null) { ACDebug.LogError("A References file is required - please use the Adventure Creator window to create one."); EditorGUILayout.LabelField("No References file found!"); } else { if (AdvGame.GetReferences().inventoryManager) { inventoryManager = AdvGame.GetReferences().inventoryManager; } if (AdvGame.GetReferences().cursorManager) { cursorManager = AdvGame.GetReferences().cursorManager; } if (AdvGame.GetReferences().settingsManager) { settingsManager = AdvGame.GetReferences().settingsManager; } if (Application.isPlaying) { if (_target.gameObject.layer != LayerMask.NameToLayer(settingsManager.hotspotLayer)) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } if (_target.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString()); } _target.interactionSource = (AC.InteractionSource)EditorGUILayout.EnumPopup("Interaction source:", _target.interactionSource); _target.hotspotName = EditorGUILayout.TextField("Label (if not name):", _target.hotspotName); _target.highlight = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", _target.highlight, typeof(Highlight), true); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace) { _target.iconSortingLayer = EditorGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer); _target.iconSortingOrder = EditorGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder); } EditorGUILayout.BeginHorizontal(); _target.centrePoint = (Transform)EditorGUILayout.ObjectField("Centre point (override):", _target.centrePoint, typeof(Transform), true); if (_target.centrePoint == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Hotspot centre: " + _target.gameObject.name; GameObject go = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false); go.name = prefabName; go.transform.position = _target.transform.position; _target.centrePoint = go.transform; if (GameObject.Find("_Markers")) { go.transform.parent = GameObject.Find("_Markers").transform; } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _target.walkToMarker = (Marker)EditorGUILayout.ObjectField("Walk-to Marker:", _target.walkToMarker, typeof(Marker), true); if (_target.walkToMarker == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Marker"; if (SceneSettings.IsUnity2D()) { prefabName += "2D"; } Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>(); newMarker.gameObject.name += (": " + _target.gameObject.name); newMarker.transform.position = _target.transform.position; _target.walkToMarker = newMarker; } } EditorGUILayout.EndHorizontal(); _target.limitToCamera = (_Camera)EditorGUILayout.ObjectField("Limit to camera:", _target.limitToCamera, typeof(_Camera), true); EditorGUILayout.BeginHorizontal(); _target.interactiveBoundary = (InteractiveBoundary)EditorGUILayout.ObjectField("Interactive boundary:", _target.interactiveBoundary, typeof(InteractiveBoundary), true); if (_target.interactiveBoundary == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "InteractiveBoundary"; if (SceneSettings.IsUnity2D()) { prefabName += "2D"; } InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>(); newInteractiveBoundary.gameObject.name += (": " + _target.gameObject.name); newInteractiveBoundary.transform.position = _target.transform.position; _target.interactiveBoundary = newInteractiveBoundary; UnityVersionHandler.PutInFolder(newInteractiveBoundary.gameObject, "_Hotspots"); } } EditorGUILayout.EndHorizontal(); _target.drawGizmos = EditorGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos); if (settingsManager != null && (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)) { _target.oneClick = EditorGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick); } if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)) { _target.doubleClickingHotspot = (DoubleClickingHotspot)EditorGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot); } if (settingsManager != null && settingsManager.playerFacesHotspots) { _target.playerTurnsHead = EditorGUILayout.Toggle("Turn head active?", _target.playerTurnsHead); } EditorGUILayout.Space(); UseInteractionGUI(); if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript) { EditorGUILayout.Space(); LookInteractionGUI(); } EditorGUILayout.Space(); InvInteractionGUI(); EditorGUILayout.Space(); UnhandledInvInteractionGUI(); } UnityVersionHandler.CustomSetDirty(_target); }
protected void SharedGUI (DragBase _target, bool isOnHinge) { CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Collision settings:", EditorStyles.boldLabel); _target.ignorePlayerCollider = CustomGUILayout.ToggleLeft ("Ignore Player's collider?", _target.ignorePlayerCollider, "", "If True, then the Physics system will ignore collisions between this object and the player"); _target.ignoreMoveableRigidbodies = CustomGUILayout.ToggleLeft ("Ignore Moveable Rigidbodies?", _target.ignoreMoveableRigidbodies, "", " If True, then the Physics system will ignore collisions between this object and the bounday colliders of any DragTrack that this is not locked to"); _target.childrenShareLayer = CustomGUILayout.ToggleLeft ("Place children on same layer?", _target.childrenShareLayer, "", "If True, then this object's children will be placed on the same layer"); EditorGUILayout.BeginHorizontal (); _target.interactiveBoundary = (InteractiveBoundary) CustomGUILayout.ObjectField <InteractiveBoundary> ("Interactive boundary:", _target.interactiveBoundary, true, "", "If assigned, then the draggable will only be interactive when the player is within this Trigger Collider's boundary"); if (_target.interactiveBoundary == null) { if (GUILayout.Button ("Create", GUILayout.MaxWidth (90f))) { string prefabName = "InteractiveBoundary"; if (SceneSettings.IsUnity2D ()) { prefabName += "2D"; } InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab ("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>(); newInteractiveBoundary.gameObject.name += (": " + _target.gameObject.name); newInteractiveBoundary.transform.position = _target.transform.position; _target.interactiveBoundary = newInteractiveBoundary; UnityVersionHandler.PutInFolder (newInteractiveBoundary.gameObject, "_Hotspots"); } } EditorGUILayout.EndHorizontal (); _target.limitToCamera = (_Camera) CustomGUILayout.ObjectField <_Camera> ("Limit to camera:", _target.limitToCamera, true, "", "If assigned, then the draggable will only be interactive when the assigned _Camera is active"); CustomGUILayout.EndVertical (); CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Icon settings:", EditorStyles.boldLabel); _target.showIcon = CustomGUILayout.Toggle ("Icon at contact point?", _target.showIcon, "", "If True, then an icon will be displayed at the 'grab point' when the object is held"); if (_target.showIcon) { if (cursorManager && cursorManager.cursorIcons.Count > 0) { int cursorInt = cursorManager.GetIntFromID (_target.iconID); cursorInt = CustomGUILayout.Popup ("Cursor icon:", cursorInt, cursorManager.GetLabelsArray (), "", "The cursor that gets shown when held"); _target.iconID = cursorManager.cursorIcons [cursorInt].id; } else { _target.iconID = -1; } } CustomGUILayout.EndVertical (); CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Sound settings:", EditorStyles.boldLabel); _target.moveSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Move sound:", _target.moveSoundClip, false, "", "The sound to play when the object is moved"); _target.slideSoundThreshold = CustomGUILayout.FloatField ("Min. move speed:", _target.slideSoundThreshold, "", "The minimum speed that the object must be moving by for sound to play"); _target.slidePitchFactor = CustomGUILayout.FloatField ("Pitch factor:", _target.slidePitchFactor, "", "The factor by which the movement sound's pitch is adjusted in relation to speed"); _target.collideSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Collide sound:", _target.collideSoundClip, false, "", "The sound to play when the object has a collision"); if (isOnHinge) { _target.onlyPlayLowerCollisionSound = CustomGUILayout.Toggle ("Only on lower boundary?", _target.onlyPlayLowerCollisionSound, "", "If True, then the collision sound will only play when the object collides with its lower boundary collider"); } CustomGUILayout.EndVertical (); }
public override void OnInspectorGUI() { Moveable_PickUp _target = (Moveable_PickUp)target; GetReferences(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel); _target.maxSpeed = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed); _target.playerMovementReductionFactor = EditorGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f); _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput); _target.breakForce = EditorGUILayout.FloatField("Break force:", _target.breakForce); _target.initialLift = EditorGUILayout.Slider("Initial lift:", _target.initialLift, 0f, 1f); EditorGUILayout.BeginHorizontal(); _target.interactionOnGrab = (Interaction)EditorGUILayout.ObjectField("Interaction on grab:", _target.interactionOnGrab, typeof(Interaction), true); if (_target.interactionOnGrab == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name); _target.interactionOnGrab = newInteraction; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Rotation settings:", EditorStyles.boldLabel); _target.allowRotation = EditorGUILayout.Toggle("Allow rotation?", _target.allowRotation); if (_target.allowRotation) { _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Zoom settings:", EditorStyles.boldLabel); _target.allowZooming = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming); if (_target.allowZooming) { _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed); _target.minZoom = EditorGUILayout.FloatField("Closest distance:", _target.minZoom); _target.maxZoom = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Throw settings:", EditorStyles.boldLabel); _target.allowThrow = EditorGUILayout.Toggle("Allow throwing?", _target.allowThrow); if (_target.allowThrow) { _target.throwForce = EditorGUILayout.FloatField("Force scale:", _target.throwForce); _target.chargeTime = EditorGUILayout.FloatField("Charge time:", _target.chargeTime); _target.pullbackDistance = EditorGUILayout.FloatField("Pull-back distance:", _target.pullbackDistance); } EditorGUILayout.EndVertical(); SharedGUI(_target, false); DisplayInputList(_target); UnityVersionHandler.CustomSetDirty(_target); }
private void NodeWindow (int ID) { if (ID == -2) { GUILayout.Label (lastConversation.gameObject.name); } else if (ID == -1) { GUILayout.Label (conversation.gameObject.name); } else if (ID < conversation.options.Count) { GUILayout.BeginHorizontal (); conversation.options[ID].label = GUILayout.TextField (conversation.options[ID].label); if (GUILayout.Button ("-", GUILayout.Width (20f))) { Undo.RecordObject (this, "Delete dialogue option"); foreach (ButtonDialog option in conversation.options) { option.isEditing = false; } conversation.selectedOption = null; conversation.options.RemoveAt (ID); } GUILayout.EndHorizontal (); } else if (ID < conversation.options.Count * 2) { int i = ID - conversation.options.Count; if (conversation.interactionSource == InteractionSource.AssetFile) { conversation.options[i].assetFile = (ActionListAsset) EditorGUILayout.ObjectField (conversation.options[i].assetFile, typeof (ActionListAsset), false); } else if (conversation.interactionSource == InteractionSource.CustomScript) { GUILayout.Label ("(Set in Inspector)"); } else if (conversation.interactionSource == InteractionSource.InScene) { if (conversation.options[i].dialogueOption != null) { GUILayout.BeginHorizontal (); string label = conversation.options[i].dialogueOption.gameObject.name; if (label.Length > 22) { label = label.Substring (0,22); } if (GUILayout.Button (label)) { if (conversation.interactionSource == InteractionSource.InScene) { Selection.activeGameObject = conversation.options[i].dialogueOption.gameObject; } } if (GUILayout.Button ("", Resource.NodeSkin.customStyles[13])) { if (conversation.interactionSource == InteractionSource.InScene) { ActionListEditorWindow.Init (conversation.options[i].dialogueOption); } else { ActionListEditorWindow.Init (conversation.options[i].dialogueOption.assetFile); } } GUILayout.EndHorizontal (); } else { GUILayout.BeginHorizontal (); GUILayout.Label ("(Not set)"); if (GUILayout.Button ("Create")) { Undo.RecordObject (conversation, "Auto-create dialogue option"); DialogueOption newDialogueOption = SceneManager.AddPrefab ("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>(); newDialogueOption.gameObject.name = AdvGame.UniqueName (conversation.gameObject.name + "_Option"); newDialogueOption.Initialise (); EditorUtility.SetDirty (newDialogueOption); conversation.options[i].dialogueOption = newDialogueOption; } GUILayout.EndHorizontal (); } } } else if (ID < conversation.options.Count * 3) { int i = ID - (conversation.options.Count*2); conversation.options[i].conversationAction = (ConversationAction) EditorGUILayout.EnumPopup (conversation.options[i].conversationAction); } else { int i = ID - (conversation.options.Count*3); if (conversation.options[i].newConversation != null) { conversation.options[i].newConversation = (Conversation) EditorGUILayout.ObjectField (conversation.options[i].newConversation, typeof (Conversation), true); } else { GUILayout.BeginHorizontal (); conversation.options[i].newConversation = (Conversation) EditorGUILayout.ObjectField (conversation.options[i].newConversation, typeof (Conversation), true); if (GUILayout.Button ("Create")) { Undo.RecordObject (conversation, "Auto-create conversation"); Conversation newConversation = SceneManager.AddPrefab ("Logic", "Conversation", true, false, true).GetComponent <Conversation>(); conversation.options[i].newConversation = newConversation; } GUILayout.EndHorizontal (); } } }
public override void OnInspectorGUI() { Moveable_Drag _target = (Moveable_Drag)target; GetReferences(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Movement settings:", EditorStyles.boldLabel); _target.maxSpeed = CustomGUILayout.FloatField("Max speed:", _target.maxSpeed, "", "The maximum force magnitude that can be applied to itself"); _target.playerMovementReductionFactor = CustomGUILayout.Slider("Player motion reduction:", _target.playerMovementReductionFactor, 0f, 1f, "", "How much player movement is reduced by when the object is being dragged"); _target.playerMovementInfluence = CustomGUILayout.FloatField("Player motion influence:", _target.playerMovementInfluence, "", "The influence that player movement has on the drag force"); _target.invertInput = CustomGUILayout.Toggle("Invert input?", _target.invertInput, "", "If True, input vectors will be inverted"); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Drag settings:", EditorStyles.boldLabel); _target.dragMode = (DragMode)CustomGUILayout.EnumPopup("Drag mode:", _target.dragMode, "", "The way in which the object can be dragged"); if (_target.dragMode == DragMode.LockToTrack) { _target.track = (DragTrack)CustomGUILayout.ObjectField <DragTrack> ("Track to stick to:", _target.track, true, "", "The DragTrack the object is locked to"); if (_target.track != null && _target.track.UsesEndColliders && _target.GetComponent <SphereCollider>() == null) { EditorGUILayout.HelpBox("For best results, ensure the first collider on this GameObject is a Sphere Collider covering the breath of the mesh.\r\nIt can be disabled if necessary, but will be used to set correct limit boundaries.", MessageType.Info); } _target.setOnStart = CustomGUILayout.ToggleLeft("Set starting position?", _target.setOnStart, "", "If True, then the object will be placed at a specific point along the track when the game begins"); if (_target.setOnStart) { _target.trackValueOnStart = CustomGUILayout.Slider("Initial distance along:", _target.trackValueOnStart, 0f, 1f, "", "How far along its DragTrack that the object should be placed at when the game begins"); } _target.retainOriginalTransform = CustomGUILayout.ToggleLeft("Maintain original child transforms?", _target.retainOriginalTransform, "", "If True, then the position and rotation of all child objects will be maintained when the object is attached to the track"); if (Application.isPlaying && _target.track != null) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Distance along: " + _target.GetPositionAlong().ToString(), EditorStyles.miniLabel); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Interactions", EditorStyles.boldLabel); _target.actionListSource = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.actionListSource, "", "The source of the commands that are run when the object is interacted with"); if (_target.actionListSource == ActionListSource.InScene) { EditorGUILayout.BeginHorizontal(); _target.interactionOnMove = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction on move:", _target.interactionOnMove, true, "", "The Interaction to run whenever the object is moved by the player"); if (_target.interactionOnMove == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name); _target.interactionOnMove = newInteraction; } } EditorGUILayout.EndHorizontal(); if (_target.interactionOnMove != null && _target.interactionOnMove.source == ActionListSource.InScene && _target.interactionOnMove.useParameters && _target.interactionOnMove.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("Drag parameter:", _target.interactionOnMove.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this draggable object"); EditorGUILayout.EndHorizontal(); } else if (_target.interactionOnMove != null && _target.interactionOnMove.source == ActionListSource.AssetFile && _target.interactionOnMove.assetFile != null && _target.interactionOnMove.assetFile.useParameters && _target.interactionOnMove.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("Drag parameter:", _target.interactionOnMove.assetFile.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this draggable object"); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); _target.interactionOnDrop = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction on let go:", _target.interactionOnDrop, true, "", "The Interaction to run whenever the object is let go by the player"); if (_target.interactionOnDrop == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("LetGo : " + _target.gameObject.name); _target.interactionOnDrop = newInteraction; } } EditorGUILayout.EndHorizontal(); if (_target.interactionOnDrop != null) { if (_target.interactionOnDrop.source == ActionListSource.InScene && _target.interactionOnDrop.useParameters && _target.interactionOnDrop.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnDrop.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } else if (_target.interactionOnDrop.source == ActionListSource.AssetFile && _target.interactionOnDrop.assetFile != null && _target.interactionOnDrop.assetFile.useParameters && _target.interactionOnDrop.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnDrop.assetFile.parameters, _target.dropParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } } } else if (_target.actionListSource == ActionListSource.AssetFile) { _target.actionListAssetOnMove = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction on move:", _target.actionListAssetOnMove, true, "", "The ActionList asset to run whenever the object is moved by the player"); if (_target.actionListAssetOnMove != null && _target.actionListAssetOnMove.useParameters && _target.actionListAssetOnMove.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("Drag parameter:", _target.actionListAssetOnMove.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this draggable object"); EditorGUILayout.EndHorizontal(); } _target.actionListAssetOnDrop = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction on let go:", _target.actionListAssetOnDrop, true, "", "The ActionList asset to run whenever the object is let go by the player"); if (_target.actionListAssetOnDrop != null && _target.actionListAssetOnDrop.useParameters && _target.actionListAssetOnDrop.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("Drag parameter:", _target.actionListAssetOnDrop.parameters, _target.dropParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this draggable object"); EditorGUILayout.EndHorizontal(); } } } else if (_target.dragMode == DragMode.MoveAlongPlane) { _target.alignMovement = (AlignDragMovement)CustomGUILayout.EnumPopup("Align movement:", _target.alignMovement, "", "What movement is aligned to"); if (_target.alignMovement == AlignDragMovement.AlignToPlane) { _target.plane = (Transform)CustomGUILayout.ObjectField <Transform> ("Movement plane:", _target.plane, true, "", "The plane to align movement to"); } _target.noGravityWhenHeld = CustomGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld, "", "If True, then gravity will be disabled on the object while it is held by the player"); } else if (_target.dragMode == DragMode.RotateOnly) { _target.rotationFactor = CustomGUILayout.FloatField("Rotation factor:", _target.rotationFactor, "", "The speed by which the object can be rotated"); _target.allowZooming = CustomGUILayout.Toggle("Allow zooming?", _target.allowZooming, "", "If True, the object can be moved towards and away from the camera"); if (_target.allowZooming) { _target.zoomSpeed = CustomGUILayout.FloatField("Zoom speed:", _target.zoomSpeed, "", "The speed at which the object can be moved towards and away from the camera"); _target.minZoom = CustomGUILayout.FloatField("Closest distance:", _target.minZoom, "", "The minimum distance that there can be between the object and the camera"); _target.maxZoom = CustomGUILayout.FloatField("Farthest distance:", _target.maxZoom, "", "The maximum distance that there can be between the object and the camera"); } _target.noGravityWhenHeld = CustomGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld, "", "If True, then gravity will be disabled on the object while it is held by the player"); } EditorGUILayout.EndVertical(); if (_target.dragMode == DragMode.LockToTrack && _target.track is DragTrack_Hinge) { SharedGUI(_target, true); } else { SharedGUI(_target, false); } DisplayInputList(_target); UnityVersionHandler.CustomSetDirty(_target); }
public override void OnInspectorGUI() { Moveable_PickUp _target = (Moveable_PickUp)target; GetReferences(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel); _target.maxSpeed = CustomGUILayout.FloatField("Max speed:", _target.maxSpeed, "", "The maximum force magnitude that can be applied to itself"); _target.playerMovementReductionFactor = CustomGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f, "", "How much player movement is reduced by when the object is being dragged"); _target.invertInput = CustomGUILayout.Toggle("Invert input?", _target.invertInput, "", "If True, input vectors will be inverted"); _target.breakForce = CustomGUILayout.FloatField("Break force:", _target.breakForce, "", "The maximum force magnitude that can be applied by the player - if exceeded, control will be removed"); _target.initialLift = CustomGUILayout.Slider("Initial lift:", _target.initialLift, 0f, 1f, "", "The lift to give objects picked up, so that they aren't touching the ground when initially held"); EditorGUILayout.BeginHorizontal(); _target.interactionOnGrab = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction on grab:", _target.interactionOnGrab, true, "", "The Interaction to run whenever the object is picked up by the player"); if (_target.interactionOnGrab == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name); _target.interactionOnGrab = newInteraction; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Rotation settings:", EditorStyles.boldLabel); _target.allowRotation = CustomGUILayout.Toggle("Allow rotation?", _target.allowRotation, "", "If True, the object can be rotated"); if (_target.allowRotation) { _target.rotationFactor = CustomGUILayout.FloatField("Rotation factor:", _target.rotationFactor, "", "The speed by which the object can be rotated"); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Zoom settings:", EditorStyles.boldLabel); _target.allowZooming = CustomGUILayout.Toggle("Allow zooming?", _target.allowZooming, "", "If True, the object can be moved towards and away from the camera"); if (_target.allowZooming) { _target.zoomSpeed = CustomGUILayout.FloatField("Zoom speed:", _target.zoomSpeed, "", "The speed at which the object can be moved towards and away from the camera"); _target.minZoom = CustomGUILayout.FloatField("Closest distance:", _target.minZoom, "", "The minimum distance that there can be between the object and the camera"); _target.maxZoom = CustomGUILayout.FloatField("Farthest distance:", _target.maxZoom, "", "The maximum distance that there can be between the object and the camera"); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Throw settings:", EditorStyles.boldLabel); _target.allowThrow = CustomGUILayout.Toggle("Allow throwing?", _target.allowThrow, "", "If True, the object can be thrown"); if (_target.allowThrow) { _target.throwForce = CustomGUILayout.FloatField("Force scale:", _target.throwForce, "", "How far the object can be thrown"); _target.chargeTime = CustomGUILayout.FloatField("Charge time:", _target.chargeTime, "", "How long a 'charge' takes, if the object cen be thrown"); _target.pullbackDistance = CustomGUILayout.FloatField("Pull-back distance:", _target.pullbackDistance, "", "How far the object is pulled back while chargine, if the object can be thrown"); } EditorGUILayout.EndVertical(); SharedGUI(_target, false); DisplayInputList(_target); UnityVersionHandler.CustomSetDirty(_target); }
private void ButtonGUI(Button button, string suffix, InteractionSource source) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false); } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true); button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction); } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); string hotspotName = _target.gameObject.name; if (_target.hotspotName != "") { hotspotName = _target.hotspotName; } newInteraction.gameObject.name = AdvGame.UniqueName(hotspotName + ": " + suffix); button.interaction = newInteraction; } } EditorGUILayout.EndHorizontal(); } button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (KickStarter.settingsManager == null || KickStarter.settingsManager.movementMethod != MovementMethod.UltimateFPS) { button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking); } button.faceAfter = EditorGUILayout.Toggle("Face after moving?", button.faceAfter); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity); if (button.setProximity) { button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity); } } } }
private void EditOptionGUI(ButtonDialog option, InteractionSource source) { CustomGUILayout.BeginVertical(); if (option.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString()); } option.label = CustomGUILayout.TextField("Label:", option.label, "", "The option's display label"); if (source == InteractionSource.AssetFile) { option.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", option.assetFile, false, "", "The ActionListAsset to run"); } else if (source == InteractionSource.CustomScript) { option.customScriptObject = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", option.customScriptObject, true, "", "The GameObject with the custom script to run"); option.customScriptFunction = CustomGUILayout.TextField("Message to send:", option.customScriptFunction, "", "The name of the function to run"); } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); option.dialogueOption = (DialogueOption)CustomGUILayout.ObjectField <DialogueOption> ("DialogOption:", option.dialogueOption, true, "", "The DialogOption to run"); if (option.dialogueOption == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Auto-create dialogue option"); DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>(); newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option"); newDialogueOption.Initialise(); EditorUtility.SetDirty(newDialogueOption); option.dialogueOption = newDialogueOption; } } EditorGUILayout.EndHorizontal(); } option.cursorIcon.ShowGUI(false, true, "Icon texture:", CursorRendering.Software, "", "The icon to display in DialogList menu elements"); option.isOn = CustomGUILayout.Toggle("Is enabled?", option.isOn, "", "If True, the option is enabled, and will be displayed in a MenuDialogList element"); if (source == InteractionSource.CustomScript) { EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info); } else { option.conversationAction = (ConversationAction)CustomGUILayout.EnumPopup("When finished:", option.conversationAction, "", "What happens when the DialogueOption ActionList has finished"); if (option.conversationAction == AC.ConversationAction.RunOtherConversation) { option.newConversation = (Conversation)CustomGUILayout.ObjectField <Conversation> ("Conversation to run:", option.newConversation, true, "", "The new Conversation to run"); } } option.linkToInventory = CustomGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory, "", " If True, then the option will only be visible if a given inventory item is being carried"); if (option.linkToInventory) { option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID); } CustomGUILayout.EndVertical(); }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\_]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); if (button.parameterID >= 0 && _target.GetComponent <ConstantID>() == null) { EditorGUILayout.HelpBox("A Constant ID component must be added to the Hotspot in order for it to be passed as a parameter.", MessageType.Warning); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true); button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix); button.interaction = newInteraction; } } else { if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); } } button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking); button.faceAfter = EditorGUILayout.Toggle("Face after moving?", button.faceAfter); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity); if (button.setProximity) { button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity); } } } }
public override void OnInspectorGUI() { if (AdvGame.GetReferences() == null) { ACDebug.LogError("A References file is required - please use the Adventure Creator window to create one."); EditorGUILayout.LabelField("No References file found!"); } else { if (AdvGame.GetReferences().inventoryManager) { inventoryManager = AdvGame.GetReferences().inventoryManager; } if (AdvGame.GetReferences().cursorManager) { cursorManager = AdvGame.GetReferences().cursorManager; } if (AdvGame.GetReferences().settingsManager) { settingsManager = AdvGame.GetReferences().settingsManager; } if (Application.isPlaying) { if (_target.gameObject.layer != LayerMask.NameToLayer(settingsManager.hotspotLayer)) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } if (_target.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString()); } _target.interactionSource = (AC.InteractionSource)CustomGUILayout.EnumPopup("Interaction source:", _target.interactionSource, "", "The source of the commands that are run when an option is chosen"); _target.hotspotName = CustomGUILayout.TextField("Label (if not name):", _target.hotspotName, "", "The display name, if not the GameObject's name"); _target.highlight = (Highlight)CustomGUILayout.ObjectField <Highlight> ("Object to highlight:", _target.highlight, true, "", "The Highlight component that controls any highlighting effects associated with the Hotspot"); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace) { _target.iconSortingLayer = CustomGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer, "", "The 'Sorting Layer' of the icon's SpriteRenderer"); _target.iconSortingOrder = CustomGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder, "", "The 'Order in Layer' of the icon's SpriteRenderer"); } EditorGUILayout.BeginHorizontal(); _target.centrePoint = (Transform)CustomGUILayout.ObjectField <Transform> ("Centre point (override):", _target.centrePoint, true, "", "A Transform that represents the centre of the Hotspot, if it is not physically at the same point as the Hotspot's GameObject itself"); if (_target.centrePoint == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Hotspot centre: " + _target.gameObject.name; GameObject go = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false); go.name = prefabName; go.transform.position = _target.transform.position; _target.centrePoint = go.transform; go.transform.parent = _target.transform; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _target.walkToMarker = (Marker)CustomGUILayout.ObjectField <Marker> ("Walk-to Marker:", _target.walkToMarker, true, "", "The Marker that the player can optionally automatically walk to before an Interaction runs"); if (_target.walkToMarker == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "Marker"; if (SceneSettings.IsUnity2D()) { prefabName += "2D"; } Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>(); newMarker.gameObject.name += (": " + _target.gameObject.name); newMarker.transform.position = _target.transform.position; _target.walkToMarker = newMarker; } } EditorGUILayout.EndHorizontal(); _target.limitToCamera = (_Camera)CustomGUILayout.ObjectField <_Camera> ("Limit to camera:", _target.limitToCamera, true, "", "If assigned, then the Hotspot will only be interactive when the assigned _Camera is active"); EditorGUILayout.BeginHorizontal(); _target.interactiveBoundary = (InteractiveBoundary)CustomGUILayout.ObjectField <InteractiveBoundary> ("Interactive boundary:", _target.interactiveBoundary, true, "", "If assigned, then the Hotspot will only be interactive when the player is within this Trigger Collider's boundary"); if (_target.interactiveBoundary == null) { if (GUILayout.Button("Create", autoWidth)) { string prefabName = "InteractiveBoundary"; if (SceneSettings.IsUnity2D()) { prefabName += "2D"; } InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>(); newInteractiveBoundary.gameObject.name += (": " + _target.gameObject.name); newInteractiveBoundary.transform.position = _target.transform.position; _target.interactiveBoundary = newInteractiveBoundary; UnityVersionHandler.PutInFolder(newInteractiveBoundary.gameObject, "_Hotspots"); } } EditorGUILayout.EndHorizontal(); _target.drawGizmos = CustomGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos, "", "If True, then a Gizmo may be drawn in the Scene window at the Hotspots's position"); if (settingsManager != null && (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)) { _target.oneClick = CustomGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick, "", "If True, then clicking the Hotspot will run the Hotspot's first interaction in useButtons, regardless of the Settings Manager's Interaction method"); if (_target.oneClick && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript) { EditorGUILayout.HelpBox("The above property can be accessed by reading the Hotspot script's IsSingleInteraction() method.", MessageType.Info); } } if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)) { if (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript) { } else { _target.doubleClickingHotspot = (DoubleClickingHotspot)CustomGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot, "", "The effect that double-clicking on the Hotspot has"); } } if (settingsManager != null && settingsManager.playerFacesHotspots) { _target.playerTurnsHead = CustomGUILayout.Toggle("Players turn heads when active?", _target.playerTurnsHead, "", "If True, then the player will turn their head when the Hotspot is selected"); } EditorGUILayout.Space(); UseInteractionGUI(); if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript) { EditorGUILayout.Space(); LookInteractionGUI(); } EditorGUILayout.Space(); InvInteractionGUI(); EditorGUILayout.Space(); UnhandledInvInteractionGUI(); } UnityVersionHandler.CustomSetDirty(_target); }
private void ButtonGUI(Button button, string suffix, InteractionSource source) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); if (button.parameterID >= 0 && _target.GetComponent <ConstantID>() == null) { EditorGUILayout.HelpBox("A Constant ID component must be added to the Hotspot in order for it to be passed as a parameter.", MessageType.Warning); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true); button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction); } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); string hotspotName = _target.gameObject.name; if (_target != null && _target.hotspotName != null && _target.hotspotName.Length > 0) { hotspotName = _target.hotspotName; } newInteraction.gameObject.name = AdvGame.UniqueName(hotspotName + ": " + suffix); button.interaction = newInteraction; } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); } } button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking); button.faceAfter = EditorGUILayout.Toggle("Face after moving?", button.faceAfter); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity); if (button.setProximity) { button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity); } } } }
public override void OnInspectorGUI() { Moveable_Drag _target = (Moveable_Drag)target; GetReferences(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel); _target.maxSpeed = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed); _target.playerMovementReductionFactor = EditorGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f); _target.playerMovementInfluence = EditorGUILayout.FloatField("Player movement influence:", _target.playerMovementInfluence); _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Drag settings:", EditorStyles.boldLabel); _target.dragMode = (DragMode)EditorGUILayout.EnumPopup("Drag mode:", _target.dragMode); if (_target.dragMode == DragMode.LockToTrack) { _target.track = (DragTrack)EditorGUILayout.ObjectField("Track to stick to:", _target.track, typeof(DragTrack), true); if (_target.track != null && _target.track is DragTrack_Straight) { EditorGUILayout.HelpBox("For best results, ensure the first collider on this GameObject is a Sphere Collider covering the breath of the mesh.\r\nIt can be disabled if necessary, but will be used to set correct limit boundaries.", MessageType.Info); } _target.setOnStart = EditorGUILayout.Toggle("Set starting position?", _target.setOnStart); if (_target.setOnStart) { _target.trackValueOnStart = EditorGUILayout.Slider("Initial distance along:", _target.trackValueOnStart, 0f, 1f); } _target.retainOriginalTransform = EditorGUILayout.ToggleLeft("Maintain original child transforms?", _target.retainOriginalTransform); EditorGUILayout.BeginHorizontal(); _target.interactionOnMove = (Interaction)EditorGUILayout.ObjectField("Interaction on move:", _target.interactionOnMove, typeof(Interaction), true); if (_target.interactionOnMove == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name); _target.interactionOnMove = newInteraction; } } EditorGUILayout.EndVertical(); } else if (_target.dragMode == DragMode.MoveAlongPlane) { _target.alignMovement = (AlignDragMovement)EditorGUILayout.EnumPopup("Align movement:", _target.alignMovement); if (_target.alignMovement == AlignDragMovement.AlignToPlane) { _target.plane = (Transform)EditorGUILayout.ObjectField("Movement plane:", _target.plane, typeof(Transform), true); } } else if (_target.dragMode == DragMode.RotateOnly) { _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor); _target.allowZooming = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming); if (_target.allowZooming) { _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed); _target.minZoom = EditorGUILayout.FloatField("Closest distance:", _target.minZoom); _target.maxZoom = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom); } } if (_target.dragMode != DragMode.LockToTrack) { _target.noGravityWhenHeld = EditorGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld); } if (Application.isPlaying && _target.dragMode == DragMode.LockToTrack && _target.track) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Distance along: " + _target.GetPositionAlong().ToString(), EditorStyles.miniLabel); } EditorGUILayout.EndVertical(); if (_target.dragMode == DragMode.LockToTrack && _target.track is DragTrack_Hinge) { SharedGUI(_target, true); } else { SharedGUI(_target, false); } UnityVersionHandler.CustomSetDirty(_target); }
private void EditOptionGUI(ButtonDialog option, InteractionSource source) { EditorGUILayout.BeginVertical("Button"); if (option.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString()); } option.label = EditorGUILayout.TextField("Label:", option.label); if (source == InteractionSource.AssetFile) { option.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", option.assetFile, typeof(ActionListAsset), false); } else if (source == InteractionSource.CustomScript) { option.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", option.customScriptObject, typeof(GameObject), true); option.customScriptFunction = EditorGUILayout.TextField("Message to send:", option.customScriptFunction); } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); option.dialogueOption = (DialogueOption)EditorGUILayout.ObjectField("Interaction:", option.dialogueOption, typeof(DialogueOption), true); if (option.dialogueOption == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Auto-create dialogue option"); DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>(); newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option"); newDialogueOption.Initialise(); EditorUtility.SetDirty(newDialogueOption); option.dialogueOption = newDialogueOption; } } EditorGUILayout.EndHorizontal(); } option.cursorIcon.ShowGUI(false, true, "Icon texture:"); option.isOn = EditorGUILayout.Toggle("Is enabled?", option.isOn); if (source == InteractionSource.CustomScript) { EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info); } else { option.conversationAction = (ConversationAction)EditorGUILayout.EnumPopup("When finished:", option.conversationAction); if (option.conversationAction == AC.ConversationAction.RunOtherConversation) { option.newConversation = (Conversation)EditorGUILayout.ObjectField("Conversation to run:", option.newConversation, typeof(Conversation), true); } } option.linkToInventory = EditorGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory); if (option.linkToInventory) { option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID); } EditorGUILayout.EndVertical(); }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", button.assetFile, false, "", "The ActionList asset to run"); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix, true); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\._]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.assetFile.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", button.customScriptObject, true, "", "The GameObject with the custom script to run"); button.customScriptFunction = CustomGUILayout.TextField("Message to send:", button.customScriptFunction, "", "The name of the function to run"); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction:", button.interaction, true, "", "The Interaction ActionList to run"); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix, false); button.interaction = newInteraction; } } else { if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.source == ActionListSource.InScene && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.interaction.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } else if (button.interaction != null && button.interaction.source == ActionListSource.AssetFile && button.interaction.assetFile != null && button.interaction.assetFile.useParameters && button.interaction.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.assetFile.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.interaction.assetFile.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } button.playerAction = (PlayerAction)CustomGUILayout.EnumPopup("Player action:", button.playerAction, "", "What the Player prefab does after clicking the Hotspot, but before the Interaction itself is run"); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = CustomGUILayout.Toggle("Cutscene while moving?", button.isBlocking, "", "If True, then gameplay will be blocked while the Player moves"); button.faceAfter = CustomGUILayout.Toggle("Face after moving?", button.faceAfter, "", "If True, then the Player will face the Hotspot after reaching the Marker"); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = CustomGUILayout.Toggle("Set minimum distance?", button.setProximity, "", "If True, then the Interaction will be run once the Player is within a certain distance of the Hotspot"); if (button.setProximity) { button.proximity = CustomGUILayout.FloatField("Proximity:", button.proximity, "", "The proximity the Player must be within"); } } } }
public override void OnInspectorGUI() { Moveable_PickUp _target = (Moveable_PickUp)target; GetReferences(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Movement settings:", EditorStyles.boldLabel); _target.maxSpeed = CustomGUILayout.FloatField("Max speed:", _target.maxSpeed, string.Empty, "The maximum force magnitude that can be applied to itself"); _target.playerMovementReductionFactor = CustomGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f, string.Empty, "How much player movement is reduced by when the object is being dragged"); _target.invertInput = CustomGUILayout.Toggle("Invert input?", _target.invertInput, string.Empty, "If True, input vectors will be inverted"); _target.breakForce = CustomGUILayout.FloatField("Break force:", _target.breakForce, string.Empty, "The maximum force magnitude that can be applied by the player - if exceeded, control will be removed"); _target.initialLift = CustomGUILayout.Slider("Initial lift:", _target.initialLift, 0f, 1f, string.Empty, "The lift to give objects picked up, so that they aren't touching the ground when initially held"); _target.autoSetConstraints = CustomGUILayout.Toggle("Auto set RB constraints?", _target.autoSetConstraints, string.Empty, "If True, the Rigidbody's constraints will be set automatically based on the state of the interaction."); _target.offScreenRelease = (OffScreenRelease)CustomGUILayout.EnumPopup("Off-screen release:", _target.offScreenRelease, string.Empty, "What should cause the object to be automatically released upon leaving the screen"); CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Interactions", EditorStyles.boldLabel); _target.actionListSource = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.actionListSource, string.Empty, "The source of the commands that are run when the object is interacted with"); if (_target.actionListSource == ActionListSource.InScene) { EditorGUILayout.BeginHorizontal(); _target.interactionOnGrab = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction on move:", _target.interactionOnGrab, true, string.Empty, "The Interaction to run whenever the object is moved by the player"); if (_target.interactionOnGrab == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + ": Grab"); _target.interactionOnGrab = newInteraction; } } EditorGUILayout.EndHorizontal(); if (_target.interactionOnGrab != null && _target.interactionOnGrab.source == ActionListSource.InScene && _target.interactionOnGrab.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnGrab.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } else if (_target.interactionOnGrab != null && _target.interactionOnGrab.source == ActionListSource.AssetFile && _target.interactionOnGrab.assetFile != null && _target.interactionOnGrab.assetFile.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnGrab.assetFile.DefaultParameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); _target.interactionOnDrop = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction on let go:", _target.interactionOnDrop, true, string.Empty, "The Interaction to run whenever the object is let go by the player"); if (_target.interactionOnDrop == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + ": LetGo"); _target.interactionOnDrop = newInteraction; } } EditorGUILayout.EndHorizontal(); if (_target.interactionOnDrop) { if (_target.interactionOnDrop.source == ActionListSource.InScene && _target.interactionOnDrop.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnDrop.parameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } else if (_target.interactionOnDrop.source == ActionListSource.AssetFile && _target.interactionOnDrop.assetFile != null && _target.interactionOnDrop.assetFile.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.interactionOnDrop.assetFile.DefaultParameters, _target.dropParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } } } else if (_target.actionListSource == ActionListSource.AssetFile) { _target.actionListAssetOnGrab = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction on grab:", _target.actionListAssetOnGrab, true, string.Empty, "The ActionList asset to run whenever the object is moved by the player"); if (_target.actionListAssetOnGrab != null && _target.actionListAssetOnGrab.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.moveParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.actionListAssetOnGrab.DefaultParameters, _target.moveParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } _target.actionListAssetOnDrop = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction on let go:", _target.actionListAssetOnDrop, true, string.Empty, "The ActionList asset to run whenever the object is let go by the player"); if (_target.actionListAssetOnDrop != null && _target.actionListAssetOnDrop.NumParameters > 0) { EditorGUILayout.BeginHorizontal(); _target.dropParameterID = Action.ChooseParameterGUI("PickUp parameter:", _target.actionListAssetOnDrop.DefaultParameters, _target.dropParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this pickup object"); EditorGUILayout.EndHorizontal(); } } CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Rotation settings:", EditorStyles.boldLabel); _target.allowRotation = CustomGUILayout.Toggle("Allow rotation?", _target.allowRotation, string.Empty, "If True, the object can be rotated"); if (_target.allowRotation) { _target.rotationFactor = CustomGUILayout.FloatField("Rotation factor:", _target.rotationFactor, string.Empty, "The speed by which the object can be rotated"); } CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Zoom settings:", EditorStyles.boldLabel); _target.allowZooming = CustomGUILayout.Toggle("Allow zooming?", _target.allowZooming, string.Empty, "If True, the object can be moved towards and away from the camera"); if (_target.allowZooming) { _target.zoomSpeed = CustomGUILayout.FloatField("Zoom speed:", _target.zoomSpeed, string.Empty, "The speed at which the object can be moved towards and away from the camera"); _target.minZoom = CustomGUILayout.FloatField("Closest distance:", _target.minZoom, string.Empty, "The minimum distance that there can be between the object and the camera"); _target.maxZoom = CustomGUILayout.FloatField("Farthest distance:", _target.maxZoom, string.Empty, "The maximum distance that there can be between the object and the camera"); } CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Throw settings:", EditorStyles.boldLabel); _target.allowThrow = CustomGUILayout.Toggle("Allow throwing?", _target.allowThrow, string.Empty, "If True, the object can be thrown"); if (_target.allowThrow) { _target.throwForce = CustomGUILayout.FloatField("Force scale:", _target.throwForce, string.Empty, "How far the object can be thrown"); _target.chargeTime = CustomGUILayout.FloatField("Charge time:", _target.chargeTime, string.Empty, "How long a 'charge' takes, if the object cen be thrown"); _target.pullbackDistance = CustomGUILayout.FloatField("Pull-back distance:", _target.pullbackDistance, string.Empty, "How far the object is pulled back while chargine, if the object can be thrown"); } CustomGUILayout.EndVertical(); SharedGUI(_target, false); DisplayInputList(_target); UnityVersionHandler.CustomSetDirty(_target); }