public MonoBase() { GameObject gameObject = new GameObject(); gameObject.name = "MonoManager"; mono = gameObject.AddComponent <MonoManager>(); GameObject.DontDestroyOnLoad(mono); }
public static bool IsAssembly(string fileName) { if (MonoManager.IsMonoAssembly(fileName)) { return(true); } return(false); }
protected override void OnExecute() { Debug.Log(log.value); if (secondsToRun > 0) { MonoManager.AddGUIMethod(OnGUI); } }
public AndroidGameStructure(FileCollection collection, string rootPath, string obbPath) : base(collection) { if (string.IsNullOrEmpty(rootPath)) { throw new ArgumentNullException(rootPath); } m_root = new DirectoryInfo(rootPath); if (!m_root.Exists) { throw new Exception($"Root directory '{rootPath}' doesn't exist"); } m_dataPath = Path.Combine(rootPath, AssetName, BinName, DataName); if (!Directory.Exists(m_dataPath)) { throw new Exception($"Data directory hasn't beed found"); } if (obbPath != null) { m_obbRoot = new DirectoryInfo(obbPath); if (!m_obbRoot.Exists) { throw new Exception($"Obb directory '{obbPath}' doesn't exist"); } m_obbDataPath = Path.Combine(obbPath, AssetName, BinName, DataName); if (!Directory.Exists(m_obbDataPath)) { throw new Exception($"Obb data directory hasn't beed found"); } } DirectoryInfo managedDirectory = new DirectoryInfo(ManagedPath); if (!managedDirectory.Exists) { throw new Exception($"Managed directory hasn't been found"); } foreach (FileInfo assemblyFile in managedDirectory.EnumerateFiles()) { if (AssemblyManager.IsAssembly(assemblyFile.Name)) { if (MonoManager.IsMonoAssembly(assemblyFile.Name)) { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono; } else { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Il2Cpp; } break; } } }
void Awake() { if (_current != null && _current != this) { DestroyImmediate(this.gameObject); return; } DontDestroyOnLoad(gameObject); _current = this; }
void AddListenerToMono() { if (ud != null) { MonoManager.GetInstance().AddUpdateListener(MyUpdate); } if (fud != null) { MonoManager.GetInstance().AddFixUpdateListener(MyFixUpdate); } }
protected override void OnExecute() { Debug.Log(log.value); if (secondsToRun > 0) { MonoManager.AddOnGUIMethod(OnGUI); } else { EndAction(finishStatus == CompactStatus.Success? true : false); } }
void RemoveAll() { MusicManager.GetInstance().RemoveMusic(); InputManager.GetInstance().StartOrEndCheck(false); EventCenter.GetInstance().RemoveEventListener <KeyCode>("某键按下", CheckInputDown); EventCenter.GetInstance().RemoveEventListener <KeyCode>("某键持续", CheckInput); EventCenter.GetInstance().RemoveEventListener <Dictionary <string, float> >("方向键", move); MonoManager.GetInstance().RemoveUpdateListener(getball); MonoManager.GetInstance().RemoveUpdateListener(checkhp); MonoManager.GetInstance().RemoveFixedUpdateListener(cdcheck); MonoManager.GetInstance().RemoveFixedUpdateListener(ghostcheck); }
static int Create(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); MonoManager.Create(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void testPhysics( ) { Material material = new Material(Shader.Find("Transparent/Diffuse")); GameObject solidPrefab = new GameObject(); objectManager = new MonoManager <SceneObject>( ); solidPrefab.AddComponent <SceneObject>( ); solidPrefab.AddComponent <MeshFilter>( ); solidPrefab.AddComponent <MeshRenderer>( ); solidPrefab.AddComponent <MeshCollider>( ); solidPrefab.AddComponent <Rigidbody>( ); objectManager.OverrideGameObject(solidPrefab); SceneObject so = objectManager.New( ); Mesh cubeMesh = Tools.Geometry.PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube); so.transform.Translate(0, 10, 0); so.GetComponent <MeshCollider>( ).sharedMesh = cubeMesh; so.GetComponent <MeshFilter>( ).sharedMesh = cubeMesh; so.GetComponent <MeshRenderer>( ).sharedMaterial = material; so.GetComponent <Rigidbody>( ).isKinematic = false; so.GetComponent <MeshCollider>( ).convex = true; //var obj = Tools.Geometry.PrimitiveHelper.CreatePrimitive(PrimitiveType.Capsule, true); //obj.transform.Translate( 0, 10, 0 ); // Floor Mesh floorMesh = Tools.Geometry.MeshGenerator.NewPlane(10, 10, 0, true); var staticManager = new MonoManager <SceneObject>( ); GameObject colliderPrefrab = new GameObject( ); colliderPrefrab.AddComponent <SceneObject>( ); colliderPrefrab.AddComponent <MeshFilter>( ); colliderPrefrab.AddComponent <MeshRenderer>( ); colliderPrefrab.AddComponent <MeshCollider>( ); staticManager.OverrideGameObject(colliderPrefrab); SceneObject floor = staticManager.New( ); floor.GetComponent <MeshCollider>( ).sharedMesh = floorMesh; floor.GetComponent <MeshFilter>( ).sharedMesh = floorMesh; floor.GetComponent <MeshRenderer>( ).sharedMaterial = material; floor.name = "Floor"; }
protected void SetScriptingBackend() { if(Assemblies.Count == 0) { return; } string assemblyPath = Assemblies.First().Value; if(MonoManager.IsMonoAssembly(assemblyPath)) { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono; } else { throw new NotImplementedException(); } }
static int set_onApplicationQuit(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); MonoManager obj = (MonoManager)o; UnityEngine.Events.UnityEvent arg0 = (UnityEngine.Events.UnityEvent)ToLua.CheckObject <UnityEngine.Events.UnityEvent>(L, 2); obj.onApplicationQuit = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onApplicationQuit on a nil value")); } }
private void AddDirectory(DirectoryInfo directory) { foreach (FileInfo file in directory.EnumerateFiles()) { if (file.Name == MainDataName) { AddFile(file.FullName); Logger.Log(LogType.Info, LogCategory.Import, $"'{MainDataName}' has been found at '{directory.FullName}'"); } else if (file.Name == GlobalGameManagerName) { AddFile(file.FullName); Logger.Log(LogType.Info, LogCategory.Import, $"'{GlobalGameManagerName}' has been found at '{directory.FullName}'"); } else if (m_levelName.IsMatch(file.Name)) { AddFile(file.FullName); Logger.Log(LogType.Info, LogCategory.Import, $"'{file.Name}' has been found at '{directory.FullName}'"); } else if (file.Extension == AssetBundleExtension) { string onlyName = Path.GetFileNameWithoutExtension(file.Name); m_files.Add(onlyName, file.FullName); Logger.Log(LogType.Info, LogCategory.Import, $"Asset bundle '{onlyName}' has been found at '{directory.FullName}'"); } else if (AssemblyManager.IsAssembly(file.Name)) { if (MonoManager.IsMonoAssembly(file.Name)) { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono; } else { throw new NotImplementedException(); } m_assemblies.Add(file.FullName); Logger.Log(LogType.Info, LogCategory.Import, $"Assembly '{file.Name}' has been found at '{directory.FullName}'"); } } foreach (DirectoryInfo subDirectory in directory.EnumerateDirectories()) { AddDirectory(subDirectory); } }
static int get_onApplicationQuit(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); MonoManager obj = (MonoManager)o; UnityEngine.Events.UnityEvent ret = obj.onApplicationQuit; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onApplicationQuit on a nil value")); } }
///Pauses the graph from updating as well as notifying all nodes and tasks. public void Pause() { if (!isRunning) { return; } runningGraphs.Remove(this); MonoManager.RemoveMethod(OnGraphUpdate); isRunning = false; isPaused = true; OnGraphPaused(); foreach (var node in allNodes) { node.OnGraphPaused(); } }
void Start() { InputManager.GetInstance().StartOrEndCheck(true); EventCenter.GetInstance().AddEventListener <KeyCode>("某键按下", CheckInputDown); EventCenter.GetInstance().AddEventListener <KeyCode>("某键持续", CheckInput); EventCenter.GetInstance().AddEventListener <Dictionary <string, float> >("方向键", move); MonoManager.GetInstance().AddUpdateListener(getball); MonoManager.GetInstance().AddUpdateListener(checkhp); MonoManager.GetInstance().AddFixedUpdateListener(cdcheck); MonoManager.GetInstance().AddFixedUpdateListener(ghostcheck); ResManager.GetInstance().LoadAsync <AudioClip>("spawn/spawn" + (Random.Range(1, 5) + 1).ToString(), (clip) => { voice.clip = clip; voice.Play(); }); LoadResources(); }
public virtual ScriptingBackend GetScriptingBackend() { if (Assemblies.Count == 0) { return(ScriptingBackend.Unknown); } string assemblyPath = Assemblies.First().Value; if (MonoManager.IsMonoAssembly(assemblyPath)) { return(ScriptingBackend.Mono); } else { throw new NotImplementedException(); } }
///Pauses the graph from updating as well as notifying all nodes and tasks. public void Pause() { if (!isRunning) { return; } runningGraphs.Remove(this); MonoManager.RemoveUpdateMethod(UpdateGraph); isRunning = false; isPaused = true; for (var i = 0; i < allNodes.Count; i++) { allNodes[i].OnGraphPaused(); } OnGraphPaused(); }
public PCGameStructure(FileCollection collection, string rootPath) : base(collection) { if (string.IsNullOrEmpty(rootPath)) { throw new ArgumentNullException(rootPath); } m_root = new DirectoryInfo(rootPath); if (!m_root.Exists) { throw new Exception($"Directory '{rootPath}' doesn't exist"); } m_dataPath = GetDataPCDirectory(m_root); if (m_dataPath == null) { throw new Exception($"Data directory hasn't been found"); } DirectoryInfo managedDirectory = new DirectoryInfo(ManagedPath); if (!managedDirectory.Exists) { throw new Exception($"Managed directory hasn't been found"); } foreach (FileInfo assemblyFile in managedDirectory.EnumerateFiles()) { if (AssemblyManager.IsAssembly(assemblyFile.Name)) { if (MonoManager.IsMonoAssembly(assemblyFile.Name)) { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono; } else { m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Il2Cpp; } break; } } }
void testDeform() { GameObject unitPrefab = new GameObject(); objectManager = new MonoManager <SceneObject>( ); // elements required to show the object in unity: unitPrefab.AddComponent <SceneObject>( ); unitPrefab.AddComponent <MeshFilter>( ); unitPrefab.AddComponent <MeshRenderer>( ); // set as instantiatable object for our factory: objectManager.OverrideGameObject(unitPrefab); SceneObject t = objectManager.New( ); //Mesh mesh = Tools.Geometry.MeshGenerator.NewCircleMesh(8, 1); Mesh mesh = Tools.Geometry.PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Sphere); Material material = new Material(Shader.Find("Transparent/Diffuse")); material.color = new Color(1, 0, 0); t.Init(mesh, material); }
// Update is called once per frame void Update() { // 测试缓存池 if (Input.GetKeyDown(KeyCode.Z)) { PoolManager.GetInstance().GetObj("Prefabs/Circle"); } // 测试公共Update if (Input.GetKeyDown(KeyCode.X)) { MonoManager.GetInstance().AddUpdateListener(KeepUpdate); } // 测试公共协程 if (Input.GetKeyDown(KeyCode.C)) { MonoManager.GetInstance().StartCoroutine(testMono()); } // 测试事件中心 if (Input.GetKeyDown(KeyCode.D)) { DoIt(); } //测试场景加载 if (Input.GetKeyDown(KeyCode.E)) { ScenesManager.GetInstance().LoadScene("SubScene", () => { Debug.Log("Enter SubScene"); }); } //测试音频加载和播放 AudioManager.GetInstance().PlayBGM("Good"); }
/// <summary> /// 检测挥动手势 /// </summary> private void DetectWavingGesture() { if ((!IsMoveLeft() && !IsMoveRight()) || !isFullOpening) { if (waveConut < 1) { isWaving = false; } return; } if (waveConut < 1) { //detectWaving = true; MonoManager.GetInstance().StartCoroutine(CheckWaveGesture()); waveConut++; preWaveVelocity = hand.PalmVelocity.x; return; } if (preWaveVelocity * hand.PalmVelocity.x < 0) { preWaveVelocity = hand.PalmVelocity.x; waveConut++; } }
public MusicManager() { MonoManager.GetInstance().AddUpdateListener(Update); }
public void RemoveMusic() { MonoManager.GetInstance().RemoveUpdateListener(Update); }
/// <summary> /// 异步加载资源 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="path"></param> /// <param name="func"></param> public void LoadResAsync <T>(string path, UnityAction <T> func) where T : Object { MonoManager.GetInstance().StartCoroutine(ReallyLoadResAsync(path, func)); }
/// <summary> /// 提供给外部的异步加载的接口方法 /// </summary> /// <param name="name"></param> /// <param name="action"></param> public void LoadSceneAsyn(string name, UnityAction action) { MonoManager.GetInstance().StartCoroutine(ReallyLoadSceneAsyn(name, action)); }
public MusicManager() { _soundSourceList = new List <AudioSource>(); MonoManager.GetInstance().AddUpdateListener(Update); }
public void LoadSceneAsync(int idx, UnityAction func) { MonoManager.GetInstance().StartCoroutine(OnLoadScene(idx, func)); }
public InputManager() { MonoManager.GetInstance().AddUpdateListener(MyUpdate); MonoManager.GetInstance().AddFixedUpdateListener(MyFixedUpdate); }
public void LoadAsync <T>(string name, UnityAction <T> callback) where T : Object { MonoManager.GetInstance().StartCoroutine(ReallyLoadAsync(name, callback)); }