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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
		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 ();
		}