private void Awake() { if (loadedData) { return; } if (KickStarter.settingsManager && GameIsPlaying() && isActiveAndEnabled) { DragBase dragBase = GetComponent <DragBase>(); if (dragBase) { if (startState == AC_OnOff.On) { dragBase.TurnOn(); } else { dragBase.TurnOff(); } } if (startState == AC_OnOff.On) { gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer); } else { gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer); } } }
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; }