@@ -122,6 +122,11 @@ public class ArmBow : MonoBehaviour
this.readyShoot();
}
+ void OnDestroy()
+ {
+ if (_ins == this) _ins = null;
+ }
+
void OnEnable()
{
AudioMgr.GetAudioSource(this.gameObject).clip = null;
@@ -50,7 +50,7 @@ public class Arrow : MonoBehaviour
void OnDestroy() {
arrowSet.Remove(this);
- GameMgr.ins.gameMode.ResumeTimeCounting(this);
+ if (GameMgr.ins) GameMgr.ins.gameMode.ResumeTimeCounting(this);
void Start()
@@ -90,6 +90,11 @@ public class BowCamera : MonoBehaviour
};
void Update()
//更新相机视野
@@ -12,4 +12,8 @@ public class CameraToLook : MonoBehaviour
ins = this;
point = transform.Find("Point");
+ if (ins == this) ins = null;
@@ -16,6 +16,11 @@ public class CrossHair : MonoBehaviour
this.image = this.GetComponent<Image>();
@@ -79,6 +79,7 @@ public class GameAssistUI : MonoBehaviour
SaveMyRecord();
+ if (ins == null) ins = null;
void Update() {
@@ -12,6 +12,11 @@ public class TargetBody : MonoBehaviour
SetDistance(distance);
TargetView targetView = TargetView.ins;
@@ -49,7 +49,7 @@ public class TargetView : MonoBehaviour
void OnDestroy()
- _ins = null;
+ if (_ins == null) _ins = null;
private static TargetView _ins = null;
@@ -9,15 +9,14 @@ public class AudioMgr : MonoBehaviour
public static void Init()
- if (GameObject.Find("AudioMgr") == null) {
+ if (!ins) {
GameObject audioMgr = new GameObject("AudioMgr");
- audioMgr.AddComponent<AudioMgr>();
+ ins = audioMgr.AddComponent<AudioMgr>();
DontDestroyOnLoad(audioMgr);
- void Start() {
- ins = this;
+ void Awake() {
this.audioSource = this.gameObject.AddComponent<AudioSource>();
@@ -53,6 +53,7 @@ public class GameMgr : MonoBehaviour
} catch (System.Exception e) { Debug.LogError(e.Message); }
if (AimHandler.ins) AimHandler.ins.Ban9AxisCalculate(false);
clearLockerForGamePause();
void FixedUpdate()
@@ -2,7 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* 内置角色信息管理者,(PK模式用到的角色选择) */
-public class RoleMgr : MonoBehaviour
+public class RoleMgr
static string[] roleNames = {"海绵宝宝", "方狗狗", "五六七", "CHANEL", "Mimi", "喵了个咪"};
public static int roleCount {
@@ -46,6 +46,7 @@ public class DeviceReconnectView : MonoBehaviour
GameMgr.ins.removeLockerForGamePause(this);
@@ -40,6 +40,11 @@ public class HomeView : MonoBehaviour
UpdateBtnForConnect();
@@ -27,6 +27,11 @@ public class TimeLimitGameView : MonoBehaviour
timeTxt.text = gameMode.GetTimeStr();