public TrackSnapConnection ShowGUI(DragTrack ownTrack, int i)
 {
     connectedTrack = (DragTrack)CustomGUILayout.ObjectField <DragTrack> ("Connected track " + i + ":", connectedTrack, true, "", "A connected track that a draggable object can transfer to when positioned at this point.");
     if (connectedTrack)
     {
         if (connectedTrack == ownTrack)
         {
             ACDebug.LogWarning(ownTrack + " cannot connect to itself", connectedTrack);
             connectedTrack = null;
         }
         else if (connectedTrack.allTrackSnapData == null || connectedTrack.allTrackSnapData.Count == 0)
         {
             //EditorGUILayout.HelpBox ("Cannot connect to this track - no snap regions defined!", MessageType.Warning);
             ACDebug.LogWarning(ownTrack + " cannot connect to track " + connectedTrack + ", - no snap regions defined", connectedTrack);
             connectedTrack = null;
         }
         else if (!connectedTrack.TypeSupportsSnapConnections())
         {
             //EditorGUILayout.HelpBox ("This track type does not support connections.", MessageType.Warning);
             ACDebug.LogWarning(ownTrack + " cannot connect to track " + connectedTrack + ", - this track type does not support connections", connectedTrack);
             connectedTrack = null;
         }
     }
     return(this);
 }
Beispiel #2
0
        /**
         * <summary>Snaps the object to a track at a given position along it</summary>
         * <param name="newTrack">The new DragTrack to snap to</param>
         * <param name="positionAlong">How far along the track, as a decimal of its length, to snap to</param>
         */
        public void SnapToTrack(DragTrack newTrack, float positionAlong)
        {
            if (newTrack == null)
            {
                return;
            }

            if (track && newTrack != track)
            {
                track.OnDisconnect(this);
            }

            dragMode = DragMode.LockToTrack;

            if (IsAutoMoving())
            {
                activeAutoMove.Stop(track, this, true);
                activeAutoMove = null;
            }

            track = newTrack;
            track.SetPositionAlong(positionAlong, this);

            if (_rigidbody)
            {
                _rigidbody.velocity        = Vector3.zero;
                _rigidbody.angularVelocity = Vector3.zero;
            }
        }
Beispiel #3
0
 public void Stop(DragTrack track, Moveable_Drag draggable, bool snapToTarget)
 {
     if (snapToTarget)
     {
         track.SetPositionAlong(targetValue, draggable);
     }
 }
Beispiel #4
0
        public override string SaveData()
        {
            TrackData data = new TrackData();

            data.objectID      = constantID;
            data.savePrevented = savePrevented;

            DragTrack track = GetComponent <DragTrack>();

            if (track && track.allTrackSnapData != null)
            {
                StringBuilder stateString = new StringBuilder();

                foreach (TrackSnapData trackSnapData in track.allTrackSnapData)
                {
                    stateString.Append(trackSnapData.ID.ToString());
                    stateString.Append(SaveSystem.colon);
                    stateString.Append(trackSnapData.IsEnabled ? "1" : "0");
                    stateString.Append(SaveSystem.pipe);
                }

                data.enabledStates = stateString.ToString();
            }

            return(Serializer.SaveScriptData <MoveableData> (data));
        }
Beispiel #5
0
 public void DrawConnectionHandles(DragTrack track)
 {
     foreach (TrackSnapConnection connection in connections)
     {
         connection.DrawHandles(GetWorldPosition(track));
     }
 }
Beispiel #6
0
 /**
  * <summary>Snaps the object to a track at a given region along it</summary>
  * <param name="newTrack">The new DragTrack to snap to</param>
  * <param name="regionID">The ID of the region to snap to. Regions are defined in the track itself</param>
  */
 public void SnapToTrack(DragTrack newTrack, int regionID)
 {
     if (newTrack == null)
     {
         return;
     }
     SnapToTrack(newTrack, newTrack.GetRegionPositionAlong(regionID));
 }
Beispiel #7
0
        public TrackSnapData ShowGUI(DragTrack dragTrack, bool useAngles)
        {
            label = CustomGUILayout.TextField("Editor label:", label, string.Empty, "The region's label when displayed in Actions.");

            bool isEnabled = !isDisabled;

            isEnabled  = CustomGUILayout.Toggle("Is enabled?", isEnabled, string.Empty, "If True, the region is enabled");
            isDisabled = !isEnabled;

            positionAlong = CustomGUILayout.Slider("Centre " + ((useAngles) ? "angle" : "position:"), positionAlong, 0f, 1f, string.Empty, "How far along the track (as a decimal) the region lies.");

            width      = CustomGUILayout.Slider("Catchment size:", width, 0f, 1f, string.Empty, "How far apart from the snapping point (as a decimal of the track's length) the object can be for this to be enforced.");
            gizmoColor = CustomGUILayout.ColorField("Editor colour:", gizmoColor, string.Empty, "What colour to draw handles in the Scene with.");

            if (dragTrack.doSnapping)
            {
                if (dragTrack.actionListSource == ActionListSource.InScene)
                {
                    cutsceneOnSnap = (Cutscene)CustomGUILayout.ObjectField <Cutscene> ("Cutscene on snap:", cutsceneOnSnap, true, "", "An optional Cutscene to run when a Draggable object snaps to this region");
                }
                else if (dragTrack.actionListSource == ActionListSource.AssetFile)
                {
                    actionListAssetOnSnap = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on snap:", actionListAssetOnSnap, false, "", "An optional ActionList asset to run when a Draggable object snaps to this region");
                }
            }

            if (dragTrack.TypeSupportsSnapConnections())
            {
                if (connections.Count == 0)
                {
                    TrackSnapConnection trackSnapConnection = new TrackSnapConnection();
                    connections.Add(trackSnapConnection);
                }

                for (int i = 0; i < connections.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    connections[i] = connections[i].ShowGUI(dragTrack, i);
                    if (GUILayout.Button("+", GUILayout.MaxWidth(20f)))
                    {
                        Undo.RecordObject(dragTrack, "Add connection");
                        TrackSnapConnection trackSnapConnection = new TrackSnapConnection();
                        connections.Insert(i + 1, trackSnapConnection);
                        i = -1;
                        break;
                    }
                    if (connections.Count > 1 && GUILayout.Button("-", GUILayout.MaxWidth(20f)))
                    {
                        Undo.RecordObject(dragTrack, "Delete connection");
                        connections.RemoveAt(i);
                        i = -1;
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            return(this);
        }
Beispiel #8
0
        public override void AssignValues(List <ActionParameter> parameters)
        {
            runtimeNewTrack   = AssignFile <DragTrack> (newTrackConstantID, newTrack);
            runtimeDragObject = AssignFile <Moveable_Drag> (parameters, dragParameterID, dragConstantID, dragObject);

            positionAlong = AssignFloat(parameters, positionParameterID, positionAlong);
            positionAlong = Mathf.Max(0f, positionAlong);
            positionAlong = Mathf.Min(1f, positionAlong);
        }
        /**
         * <summary>Creates a new instance of the 'Moveable: Toggle Track region' Action</summary>
         * <param name = "_track">The DragTrack to affect</param>
         * <param name = "_regionID">The region's ID</param>
         * <param name = "_enable">If True, the region will be enabled</param>
         * <returns>The generated Action</returns>
         */
        public static ActionTrackRegion CreateNew(DragTrack _track, int _regionID, bool _enable)
        {
            ActionTrackRegion newAction = (ActionTrackRegion)CreateInstance <ActionTrackRegion>();

            newAction.track         = _track;
            newAction.trackRegionID = _regionID;
            newAction.enable        = _enable;
            return(newAction);
        }
        public void SnapDataGUI(DragTrack _target, bool useAngles)
        {
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Track regions", EditorStyles.boldLabel);

            for (int i = 0; i < _target.allTrackSnapData.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Region " + _target.allTrackSnapData[i].ID.ToString());
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("-"))
                {
                    Undo.RecordObject(this, "Delete region");
                    _target.allTrackSnapData.RemoveAt(i);
                    i = -1;
                    break;
                }
                EditorGUILayout.EndHorizontal();

                _target.allTrackSnapData[i] = _target.allTrackSnapData[i].ShowGUI(_target, useAngles);
                EditorGUILayout.Space();

                if (i < _target.allTrackSnapData.Count - 1)
                {
                    GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
                }
            }
            if (GUILayout.Button("Create new track region"))
            {
                Undo.RecordObject(this, "Create track region");
                TrackSnapData trackSnapData = new TrackSnapData(0f, GetSnapIDArray(_target.allTrackSnapData));
                _target.allTrackSnapData.Add(trackSnapData);
            }

            CustomGUILayout.EndVertical();

            if (_target.allTrackSnapData.Count > 0)
            {
                CustomGUILayout.BeginVertical();
                EditorGUILayout.LabelField("Snapping", EditorStyles.boldLabel);

                _target.doSnapping = CustomGUILayout.Toggle("Enable region snapping?", _target.doSnapping, string.Empty, "If True, then snapping is enabled and any object attached to the track can snap to pre-set regions along it when let go by the player");
                if (_target.doSnapping)
                {
                    _target.snapSpeed = CustomGUILayout.FloatField("Snap speed:", _target.snapSpeed, string.Empty, "The speed to move by when attached objects snap");
                    _target.onlySnapOnPlayerRelease = CustomGUILayout.Toggle("Only snap on release?", _target.onlySnapOnPlayerRelease, string.Empty, "If True, then snapping will only occur when the player releases the object - and not when moving on its own accord");
                    _target.actionListSource        = (ActionListSource)CustomGUILayout.EnumPopup("ActionList source:", _target.actionListSource, string.Empty, "The source of ActionLists that can be run when a draggable option snaps to a region.");
                }

                CustomGUILayout.EndVertical();
            }


            UnityVersionHandler.CustomSetDirty(_target);
        }
Beispiel #11
0
		public override void AssignValues (List<ActionParameter> parameters)
		{
			runtimeDragObject = AssignFile <Moveable_Drag> (parameters, dragParameterID, dragConstantID, dragObject);
			runtimeDragTrack = AssignFile <DragTrack> (parameters, dragTrackParameterID, dragTrackConstantID, dragTrack);

			checkPosition = AssignFloat (parameters, checkPositionParameterID, checkPosition);
			checkPosition = Mathf.Max (0f, checkPosition);
			checkPosition = Mathf.Min (1f, checkPosition);

			snapID = AssignInteger (parameters, snapParameterID, snapID);
		}
Beispiel #12
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            dragParameterID = Action.ChooseParameterGUI("Draggable object:", parameters, dragParameterID, ParameterType.GameObject);
            if (dragParameterID >= 0)
            {
                dragConstantID = 0;
                dragObject     = null;
            }
            else
            {
                dragObject = (Moveable_Drag)EditorGUILayout.ObjectField("Draggable object:", dragObject, typeof(Moveable_Drag), true);

                dragConstantID = FieldToID <Moveable_Drag> (dragObject, dragConstantID);
                dragObject     = IDToField <Moveable_Drag> (dragObject, dragConstantID, false);

                if (dragObject != null && dragObject.dragMode != DragMode.LockToTrack)
                {
                    EditorGUILayout.HelpBox("The chosen Drag object must be in 'Lock To Track' mode", MessageType.Warning);
                }
            }

            newTrack = (DragTrack)EditorGUILayout.ObjectField("Track (optional):", newTrack, typeof(DragTrack), true);

            newTrackConstantID = FieldToID <DragTrack>(newTrack, newTrackConstantID);
            newTrack           = IDToField <DragTrack>(newTrack, newTrackConstantID, false);

            positionParameterID = Action.ChooseParameterGUI("New track position:", parameters, positionParameterID, ParameterType.Float);
            if (positionParameterID < 0)
            {
                positionAlong = EditorGUILayout.Slider("New track position:", positionAlong, 0f, 1f);
            }

            if (newTrack == null)
            {
                isInstant = EditorGUILayout.Toggle("Is instant?", isInstant);
                if (!isInstant)
                {
                    speed = EditorGUILayout.FloatField("Movement speed:", speed);
                    removePlayerControl = EditorGUILayout.Toggle("Remove player control?", removePlayerControl);
                    stopOnCollide       = EditorGUILayout.Toggle("Stop if has collision?", stopOnCollide);
                    if (stopOnCollide)
                    {
                        layerMask = AdvGame.LayerMaskField("'Stop' collision layer(s):", layerMask);
                    }

                    willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
                }
            }

            AfterRunningOption();
        }
Beispiel #13
0
        protected void SharedGUI(bool useColliders)
        {
            DragTrack _target = (DragTrack)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("End-colliders", EditorStyles.boldLabel);

            _target.discSize = CustomGUILayout.Slider("Gizmo size:", _target.discSize, 0f, 2f, "", "The size of the track's end colliders, as seen in the Scene window");
            if (useColliders)
            {
                _target.colliderMaterial = (PhysicMaterial)CustomGUILayout.ObjectField <PhysicMaterial> ("Material:", _target.colliderMaterial, false, "", "Physics Material to give the track's end colliders");
            }

            EditorGUILayout.EndVertical();

            UnityVersionHandler.CustomSetDirty(_target);
        }
        protected void SharedGUI(bool useColliders)
        {
            DragTrack _target = (DragTrack)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("End-colliders", EditorStyles.boldLabel);

            _target.discSize = EditorGUILayout.Slider("Gizmo size:", _target.discSize, 0f, 2f);
            if (useColliders)
            {
                _target.colliderMaterial = (PhysicMaterial)EditorGUILayout.ObjectField("Material:", _target.colliderMaterial, typeof(PhysicMaterial), false);
            }

            EditorGUILayout.EndVertical();

            UnityVersionHandler.CustomSetDirty(_target);
        }
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            track = (DragTrack)EditorGUILayout.ObjectField("Track:", track, typeof(DragTrack), true);

            trackConstantID = FieldToID <DragTrack> (track, trackConstantID);
            track           = IDToField <DragTrack> (track, trackConstantID, false);

            if (track)
            {
                trackRegionParameterID = Action.ChooseParameterGUI("Region ID:", parameters, trackRegionParameterID, ParameterType.Integer);
                if (trackRegionParameterID >= 0)
                {
                    enable = EditorGUILayout.Toggle("Enable?", enable);
                }
                else
                {
                    List <string> labelList = new List <string>();
                    int           snapIndex = 0;

                    if (track.allTrackSnapData != null && track.allTrackSnapData.Count > 0)
                    {
                        for (int i = 0; i < track.allTrackSnapData.Count; i++)
                        {
                            labelList.Add(track.allTrackSnapData[i].EditorLabel);

                            if (track.allTrackSnapData[i].ID == trackRegionID)
                            {
                                snapIndex = i;
                            }
                        }

                        snapIndex     = EditorGUILayout.Popup("Region:", snapIndex, labelList.ToArray());
                        trackRegionID = track.allTrackSnapData[snapIndex].ID;

                        enable = EditorGUILayout.Toggle("Enable?", enable);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("The chosen Drag object's Track has no snap points.", MessageType.Warning);
                    }
                }
            }

            AfterRunningOption();
        }
Beispiel #16
0
        public override void LoadData(string stringData)
        {
            TrackData data = Serializer.LoadScriptData <TrackData> (stringData);

            if (data == null)
            {
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            DragTrack track = GetComponent <DragTrack>();

            if (track && track.allTrackSnapData != null)
            {
                string[] valuesArray = data.enabledStates.Split(SaveSystem.pipe[0]);
                for (int i = 0; i < track.allTrackSnapData.Count; i++)
                {
                    if (i < valuesArray.Length)
                    {
                        string[] chunkData = valuesArray[i].Split(SaveSystem.colon[0]);
                        if (chunkData != null && chunkData.Length == 2)
                        {
                            int _regionID = 0;
                            if (int.TryParse(chunkData[0], out _regionID))
                            {
                                TrackSnapData snapData = track.GetSnapData(_regionID);
                                if (snapData != null)
                                {
                                    int _isEnabled = 1;
                                    if (int.TryParse(chunkData[1], out _isEnabled))
                                    {
                                        snapData.IsEnabled = (_isEnabled == 1);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #17
0
        public void SnapDataGUI(DragTrack _target, bool useAngles)
        {
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Snapping", EditorStyles.boldLabel);

            _target.doSnapping = CustomGUILayout.Toggle("Enable snapping?", _target.doSnapping, "", "If True, then snapping is enabled and any object attached to the track can snap to pre-set points along it when let go by the player");
            if (_target.doSnapping)
            {
                _target.snapSpeed = CustomGUILayout.FloatField("Snap speed:", _target.snapSpeed, "", "The speed to move by when attached objects snap");
                _target.onlySnapOnPlayerRelease = CustomGUILayout.ToggleLeft("Only snap on player release?", _target.onlySnapOnPlayerRelease, "", "If True, then snapping will only occur when the player releases the object - and not when moving on its own accord");

                for (int i = 0; i < _target.allTrackSnapData.Count; i++)
                {
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Snap " + _target.allTrackSnapData[i].ID.ToString());
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("-"))
                    {
                        Undo.RecordObject(this, "Delete snap point");
                        _target.allTrackSnapData.RemoveAt(i);
                        i = -1;
                        break;
                    }
                    EditorGUILayout.EndHorizontal();

                    _target.allTrackSnapData[i] = _target.allTrackSnapData[i].ShowGUI(useAngles);
                    EditorGUILayout.Space();
                }
                if (GUILayout.Button("Create new snap point"))
                {
                    Undo.RecordObject(this, "Create snap point");
                    TrackSnapData trackSnapData = new TrackSnapData(0f, GetSnapIDArray(_target.allTrackSnapData));
                    _target.allTrackSnapData.Add(trackSnapData);
                }
            }
            EditorGUILayout.EndVertical();

            UnityVersionHandler.CustomSetDirty(_target);
        }
Beispiel #18
0
        public void EvaluateConnectionPoints(DragTrack track, Moveable_Drag draggable, Vector3 dragForce)
        {
            if (connections == null || !IsEnabled)
            {
                return;
            }

            float ownScore = 0f;

            switch (draggable.track.dragMovementCalculation)
            {
            case DragMovementCalculation.DragVector:
                ownScore = draggable.track.GetForceDotProduct(dragForce, draggable);
                break;

            case DragMovementCalculation.CursorPosition:
                Vector2 draggableScreenPosition = KickStarter.CameraMain.WorldToScreenPoint(draggable.Transform.position);
                if (Vector2.Distance(draggableScreenPosition, KickStarter.playerInput.GetMousePosition()) < 0.05f)
                {
                    return;
                }
                ownScore = draggable.track.GetMinDistanceToScreenPoint(KickStarter.playerInput.GetMousePosition());
                break;

            default:
                break;
            }

            TrackSnapConnection winningConnection = null;
            float winningScore         = ownScore;
            float winningScoreAbsolute = Mathf.Abs(winningScore);

            foreach (TrackSnapConnection connection in connections)
            {
                float connectionScore         = connection.EvaluateInputScore(draggable.track.dragMovementCalculation, draggable, dragForce);
                float connectionScoreAbsolute = Mathf.Abs(connectionScore);

                switch (draggable.track.dragMovementCalculation)
                {
                case DragMovementCalculation.DragVector:
                    if ((connectionScoreAbsolute > winningScoreAbsolute) || (connectionScoreAbsolute == winningScoreAbsolute && connectionScore > winningScore))
                    {
                        winningScoreAbsolute = connectionScoreAbsolute;
                        winningScore         = connectionScore;
                        winningConnection    = connection;
                    }
                    break;

                case DragMovementCalculation.CursorPosition:
                    if (connectionScore < winningScore)
                    {
                        winningScore      = connectionScore;
                        winningConnection = connection;
                    }
                    break;

                default:
                    break;
                }
            }

            if (winningScoreAbsolute > 0f && winningConnection != null && draggable.track == track)
            {
                winningConnection.MakeConnection(draggable);
            }
        }
Beispiel #19
0
 public void Update(DragTrack track, Moveable_Drag draggable)
 {
     track.ApplyAutoForce(targetValue, speed, draggable);
 }
 public override void AssignValues(List <ActionParameter> parameters)
 {
     runtimeTrack  = AssignFile <DragTrack> (trackConstantID, track);
     trackRegionID = AssignInteger(parameters, trackRegionParameterID, trackRegionID);
 }
Beispiel #21
0
		public override void ShowGUI (List<ActionParameter> parameters)
		{
			dragParameterID = Action.ChooseParameterGUI ("Drag object:", parameters, dragParameterID, ParameterType.GameObject);
			if (dragParameterID < 0 || method == TrackCheckMethod.WithinTrackRegion)
			{
				string label = (dragParameterID < 0) ? "Placeholder drag object:" : "Drag object";

				dragObject = (Moveable_Drag) EditorGUILayout.ObjectField (label, dragObject, typeof (Moveable_Drag), true);
				
				dragConstantID = FieldToID <Moveable_Drag> (dragObject, dragConstantID);
				dragObject = IDToField <Moveable_Drag> (dragObject, dragConstantID, false);
				
				if (dragObject != null && dragObject.dragMode != DragMode.LockToTrack)
				{
					EditorGUILayout.HelpBox ("The chosen Drag object must be in 'Lock To Track' mode", MessageType.Warning);
				}
			}

			dragTrackParameterID = Action.ChooseParameterGUI ("Track (optional):", parameters, dragTrackParameterID, ParameterType.GameObject);
			if (dragTrackParameterID < 0)
			{
				dragTrack = (DragTrack) EditorGUILayout.ObjectField ("Track (optional):", dragTrack, typeof (DragTrack), true);

				dragTrackConstantID = FieldToID<DragTrack> (dragTrack, dragTrackConstantID);
				dragTrack = IDToField<DragTrack> (dragTrack, dragTrackConstantID, false);
			}

			method = (TrackCheckMethod) EditorGUILayout.EnumPopup ("Method:", method);
			if (method == TrackCheckMethod.PositionValue)
			{
				condition = (IntCondition) EditorGUILayout.EnumPopup ("Condition:", condition);

				checkPositionParameterID = Action.ChooseParameterGUI ("Position:", parameters, checkPositionParameterID, ParameterType.Float);
				if (checkPositionParameterID < 0)
				{
					checkPosition = EditorGUILayout.Slider ("Position:", checkPosition, 0f, 1f);
				}

				if (condition == IntCondition.EqualTo || condition == IntCondition.NotEqualTo)
				{
					errorMargin = EditorGUILayout.Slider ("Error margin:", errorMargin, 0f, 1f);
				}
			}
			else if (method == TrackCheckMethod.WithinTrackRegion)
			{
				if (dragObject == null)
				{
					EditorGUILayout.HelpBox ("A drag object must be assigned above for snap regions to display.", MessageType.Info);
				}
				else if (dragObject.dragMode != DragMode.LockToTrack)
				{
					EditorGUILayout.HelpBox ("The chosen Drag object is not locked to a Track.", MessageType.Warning);
				}
				else
				{
					snapParameterID = Action.ChooseParameterGUI ("Region ID:", parameters, snapParameterID, ParameterType.Integer);
					if (snapParameterID < 0)
					{
						List<string> labelList = new List<string>();
						int snapIndex = 0;

						DragTrack track = (dragTrack != null) ? dragTrack : dragObject.track;
						if (track && track.allTrackSnapData != null && track.allTrackSnapData.Count > 0)
						{ 
							for (int i=0; i<track.allTrackSnapData.Count; i++)
							{
								labelList.Add (track.allTrackSnapData[i].EditorLabel);
							
								if (track.allTrackSnapData[i].ID == snapID)
								{
									snapIndex = i;
								}
							}
						
							snapIndex = EditorGUILayout.Popup ("Region:", snapIndex, labelList.ToArray ());
							snapID = track.allTrackSnapData[snapIndex].ID;
						}
						else
						{
							EditorGUILayout.HelpBox("The chosen Drag object's Track has no Regions defined.", MessageType.Warning);
						}
					}
				}
			}
		}
Beispiel #22
0
 /**
  * <summary>Gets the position in world space of the centre of the snap region</summary>
  * <param name="track">The track that the snap region is a part of.</param>
  * <returns>The snap region's position in world space</returns>
  **/
 public Vector3 GetWorldPosition(DragTrack track)
 {
     return(track.GetGizmoPosition(PositionAlong));
 }
        public override void LoadData(string stringData)
        {
            MoveableData data = Serializer.LoadScriptData <MoveableData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            DragBase dragBase = GetComponent <DragBase>();

            if (dragBase)
            {
                if (data.isOn)
                {
                    dragBase.TurnOn();
                }
                else
                {
                    dragBase.TurnOff();
                }
            }

            if (data.isOn)
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer);
            }
            else
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer);
            }

            transform.position    = new Vector3(data.LocX, data.LocY, data.LocZ);
            transform.eulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ);
            transform.localScale  = new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ);

            Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();

            if (moveable_Drag)
            {
                moveable_Drag.LetGo();
                if (moveable_Drag.dragMode == DragMode.LockToTrack)
                {
                    DragTrack dragTrack = ConstantID.GetComponent <DragTrack> (data.trackID);
                    if (dragTrack)
                    {
                        moveable_Drag.SnapToTrack(dragTrack, data.trackValue);
                    }

                    if (moveable_Drag.track)
                    {
                        moveable_Drag.trackValue  = data.trackValue;
                        moveable_Drag.revolutions = data.revolutions;
                        moveable_Drag.StopAutoMove();
                        moveable_Drag.track.SetPositionAlong(data.trackValue, moveable_Drag);
                    }
                }
            }

            Moveable moveable = GetComponent <Moveable>();

            if (moveable)
            {
                moveable.LoadData(data);
            }

            loadedData = true;
        }