public static void AddCDplayer(GameObject SelectedVehicle, int Partname, bool RADIOCD, bool Channel) { CDPLAYER = GameObject.Instantiate <GameObject>(assetBundle.LoadAsset <GameObject>("CD_PLAYER.prefab")); CDPLAYER.transform.position = Vector3.zero; CDPLAYER.transform.eulerAngles = new Vector3(270f, 0f, 0f); handler = CDPLAYER.AddComponent <CDHandler>(); handler.Partname = Partname; var col = CDPLAYER.AddComponent <SphereCollider>(); col.radius = 0.1f; col.isTrigger = true; col.center = new Vector3(0f, -0.05f, 0f); functions = CDPLAYER.AddComponent <CDPlayerFunctions>(); functions.RADIOCD = RADIOCD; functions.Channel = Channel; CDPLAYER.AddComponent <InteractionRaycast>(); CDPLAYER.AddComponent <VolumeKnob>(); CDPLAYER.transform.SetParent(SelectedVehicle.transform, false); CDPLAYER.transform.localEulerAngles = Vector3.zero; if (SelectedVehicle.transform.Find("Radio") != null) { SelectedVehicle.transform.Find("Radio").gameObject.SetActive(false); } if (SelectedVehicle.transform.Find("Speaker") != null) { functions.sourcepivot = SelectedVehicle.transform.Find("Speaker"); } handler.GetCDfromLastSession(); Component.DestroyImmediate(functions.sourcepivot.GetComponent <PlayMakerFSM>()); }
public void Start() { Radio = GameObject.Find("RADIO").transform; guiUse = PlayMakerGlobals.Instance.Variables.FindFsmBool("GUIuse"); guiInteraction = PlayMakerGlobals.Instance.Variables.FindFsmString("GUIinteraction"); Hand = GameObject.Find("PLAYER").transform.Find("Pivot/AnimPivot/Camera/FPSCamera/1Hand_Assemble/Hand").GetComponent <PlayMakerFSM>(); RadioCDSwitch = transform.Find("ButtonsCD/RadioCDSwitch").GetComponent <SphereCollider>(); TrackChannelSwitch = transform.Find("ButtonsCD/TrackChannelSwitch").GetComponent <SphereCollider>(); Eject = transform.Find("ButtonsCD/Eject").GetComponent <SphereCollider>(); LCD = transform.Find("LCD").GetComponent <TextMesh>(); Raycast = GetComponent <InteractionRaycast>(); cdAudio = transform.Find("Speaker").GetComponent <AudioSource>(); Sled = transform.Find("Sled/cd_sled_pivot").GetComponent <Animation>(); Volumeknob = GetComponent <VolumeKnob>(); handler = GetComponent <CDHandler>(); GetRadio(); cdAudio.transform.SetParent(sourcepivot, false); if (GetComponent <BrennsAudioVisualizer>() != null) { audioVisualizer = GetComponent <BrennsAudioVisualizer>(); } }