private void CreateEventSystem() { m_objEventSystem = new GameObject(); m_objEventSystem.name = "EventSystem"; m_objEventSystem.layer = GameLayer.UI; m_objEventSystem.transform.SetParent(m_transRootCanvas, false); m_compEventSystem = m_objEventSystem.AddComponent<EventSystem>(); m_compSIModule = m_objEventSystem.AddComponent<StandaloneInputModule>(); m_compTIModule = m_objEventSystem.AddComponent<TouchInputModule>(); }
static public int get_allowActivationOnStandalone(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); pushValue(l, self.allowActivationOnStandalone); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int UpdateModule(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); self.UpdateModule(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int get_allowActivationOnStandalone(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); pushValue(l, true); pushValue(l, self.allowActivationOnStandalone); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int UpdateModule(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); self.UpdateModule(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int ShouldActivateModule(IntPtr l) { try{ UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); System.Boolean ret = self.ShouldActivateModule(); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int ShouldActivateModule(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); var ret = self.ShouldActivateModule(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int IsModuleSupported(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); var ret = self.IsModuleSupported(); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_allowActivationOnStandalone(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); bool v; checkType(l, 2, out v); self.allowActivationOnStandalone = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_forceModuleActive(IntPtr l) { try { UnityEngine.EventSystems.TouchInputModule self = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); bool v; checkType(l, 2, out v); self.forceModuleActive = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_allowActivationOnStandalone(IntPtr l) { UnityEngine.EventSystems.TouchInputModule o = (UnityEngine.EventSystems.TouchInputModule)checkSelf(l); pushValue(l, o.allowActivationOnStandalone); return(1); }
protected void Awake() { // TODO: it would be cool to load/save the user settings from/to disk (PlayerPrefs) UFE.config = UFE_Config; // Check which characters have been unlocked UFE.LoadUnlockedCharacters(); // Check the installed Addons and supported 3rd party products UFE.isCInputInstalled = UFE.IsInstalled("cInput"); UFE.isAiAddonInstalled = UFE.IsInstalled("RuleBasedAI"); UFE.isNetworkAddonInstalled = UFE.IsInstalled("NetworkController"); #if !UFE_BASIC UFE.isControlFreakInstalled = UFE.IsInstalled("TouchController"); #else UFE.isControlFreakInstalled = false; #endif // Check if we should run the application in background Application.runInBackground = UFE.config.runInBackground; // Check if cInput is installed and initialize the cInput GUI if (UFE.isCInputInstalled){ Type t = UFE.SearchClass("cGUI"); if (t != null) t.GetField("cSkin").SetValue(null, UFE.config.inputOptions.cInputSkin); } #if !UFE_BASIC // Check if "Control Freak Virtual Controller" is installed and instantiate the prefab if ( UFE.isControlFreakInstalled && UFE.config.inputOptions.inputManagerType == InputManagerType.ControlFreak && UFE.config.inputOptions.controlFreakPrefab != null ){ UFE.controlFreakPrefab = (GameObject) Instantiate(UFE.config.inputOptions.controlFreakPrefab); } #endif // Check if the "network addon" is installed if (UFE.isNetworkAddonInstalled){ NetworkView network = this.gameObject.AddComponent<NetworkView>(); network.stateSynchronization = NetworkStateSynchronization.Off; Network.sendRate = 1f / (float)UFE.config.fps; UFE.localPlayerController = this.gameObject.AddComponent(UFE.SearchClass("LocalPlayerController")) as UFEController; UFE.remotePlayerController = this.gameObject.AddComponent(UFE.SearchClass("RemotePlayerController")) as UFEController; network.observed = UFE.remotePlayerController; } UFE.InitializeAudioSystem(); // Initialize the input systems p1Controller = gameObject.AddComponent<UFEController> (); if (Input.multiTouchEnabled){ p1Controller.humanController = gameObject.AddComponent<InputTouchController>(); }else{ p1Controller.humanController = gameObject.AddComponent<InputController>(); } if (UFE.isAiAddonInstalled){ p1Controller.cpuController = (AbstractInputController)gameObject.AddComponent<RuleBasedAI>(); }else{ p1Controller.cpuController = gameObject.AddComponent<RandomAI>(); } p1Controller.isCPU = config.p1CPUControl; p1Controller.player = 1; p2Controller = gameObject.AddComponent<UFEController> (); p2Controller.humanController = gameObject.AddComponent<InputController>(); if (UFE.isAiAddonInstalled){ p2Controller.cpuController = (AbstractInputController )gameObject.AddComponent<RuleBasedAI>(); }else{ p2Controller.cpuController = gameObject.AddComponent<RandomAI>(); } p2Controller.isCPU = config.p2CPUControl; p2Controller.player = 2; p1Controller.Initialize(config.player1_Inputs); p2Controller.Initialize(config.player2_Inputs); if (config.fps > 0) { Time.timeScale = config.gameSpeed; Application.targetFrameRate = config.fps; } SetLanguage(); //------------------------------------------------------------------------------------------------------------- // Initialize the GUI //------------------------------------------------------------------------------------------------------------- GameObject goGroup = new GameObject("CanvasGroup"); UFE.canvasGroup = goGroup.AddComponent<CanvasGroup>(); GameObject go = new GameObject("Canvas"); go.transform.SetParent(goGroup.transform); UFE.canvas = go.AddComponent<Canvas>(); UFE.canvas.renderMode = RenderMode.ScreenSpaceOverlay; UFE.eventSystem = go.AddComponent<EventSystem>(); UFE.graphicRaycaster = go.AddComponent<GraphicRaycaster>(); UFE.touchInputModule = go.AddComponent<TouchInputModule>(); UFE.touchInputModule.allowActivationOnStandalone = true; UFE.touchInputModule.ActivateModule(); //UFE.standaloneInputModule = go.AddComponent<StandaloneInputModule>(); //UFE.standaloneInputModule.verticalAxis = "P1KeyboardVertical"; //UFE.standaloneInputModule.horizontalAxis = "P1KeyboardHorizontal"; //UFE.standaloneInputModule.allowActivationOnMobileDevice = true; if (UFE.config.gameGUI.useCanvasScaler){ CanvasScaler cs = go.AddComponent<CanvasScaler>(); cs.defaultSpriteDPI = UFE.config.gameGUI.canvasScaler.defaultSpriteDPI; cs.fallbackScreenDPI = UFE.config.gameGUI.canvasScaler.fallbackScreenDPI; cs.matchWidthOrHeight = UFE.config.gameGUI.canvasScaler.matchWidthOrHeight; cs.physicalUnit = UFE.config.gameGUI.canvasScaler.physicalUnit; cs.referencePixelsPerUnit = UFE.config.gameGUI.canvasScaler.referencePixelsPerUnit; cs.referenceResolution = UFE.config.gameGUI.canvasScaler.referenceResolution; cs.scaleFactor = UFE.config.gameGUI.canvasScaler.scaleFactor; cs.screenMatchMode = UFE.config.gameGUI.canvasScaler.screenMatchMode; cs.uiScaleMode = UFE.config.gameGUI.canvasScaler.scaleMode; //--------------------------------------------------------------------------------------------------------- // We use comment the next line because we use a "Screen Space - Overlay" canvas // and the "dynaicPixelsPerUnit" property is only used in "World Space" Canvas. //--------------------------------------------------------------------------------------------------------- //cs.dynamicPixelsPerUnit = UFE.config.gameGUI.canvasScaler.dynamicPixelsPerUnit; } // DEBUGGER GameObject debuggerGO = new GameObject("Debugger1"); UFE.debugger1 = debuggerGO.AddComponent<GUIText>(); UFE.debugger1.pixelOffset = new Vector2(55 * ((float)Screen.width/1280), 570f * ((float)Screen.height/720)); UFE.debugger1.text = "Debug mode"; UFE.debugger1.anchor = TextAnchor.UpperLeft; UFE.debugger1.color = Color.black; UFE.debugger1.richText = true; debugger1.enabled = false; GameObject debuggerGO2 = new GameObject("Debugger2"); UFE.debugger2 = debuggerGO2.AddComponent<GUIText>(); UFE.debugger2.pixelOffset = new Vector2(1225 * ((float)Screen.width/1280), 570f * ((float)Screen.height/720)); UFE.debugger2.text = "Debug mode"; UFE.debugger2.alignment = TextAlignment.Right; UFE.debugger2.anchor = TextAnchor.UpperRight; UFE.debugger2.color = Color.black; UFE.debugger2.richText = true; debugger2.enabled = false; //------------------------------------------------------------------------------------------------------------- // Load the player settings from disk UFE.SetMusic(PlayerPrefs.GetInt(UFE.MusicEnabledKey, 1) > 0); UFE.SetMusicVolume(PlayerPrefs.GetFloat(UFE.MusicVolumeKey, 1f)); UFE.SetSoundFX(PlayerPrefs.GetInt(UFE.SoundsEnabledKey, 1) > 0); UFE.SetSoundFXVolume(PlayerPrefs.GetFloat(UFE.SoundsVolumeKey, 1f)); UFE.SetDebugMode(config.debugOptions.debugMode); // Set default difficulty level /*int difficultyIndex = PlayerPrefs.GetInt(UFE.DifficultyLevelKey, -1); if (difficultyIndex >= 0 && difficultyIndex < UFE.config.aiOptions.difficultySettings.Length){ UFE.SetAIDifficulty(UFE.config.aiOptions.difficultySettings[difficultyIndex]); }else{*/ UFE.SetAIDifficulty(UFE.config.aiOptions.selectedDifficultyLevel); //} // Load the intro screen or the combat, depending on the UFE Config settings if (UFE.config.debugOptions.startGameImmediately){ if (UFE.config.debugOptions.trainingMode) { UFE.gameMode = GameMode.TrainingRoom; } else { UFE.gameMode = GameMode.VersusMode; } UFE.config.player1Character = config.p1CharStorage; UFE.config.player2Character = config.p2CharStorage; UFE.SetCPU(1, config.p1CPUControl); UFE.SetCPU(2, config.p2CPUControl); //UFE.StartGame(0); UFE._StartLoadingBattleScreen(0); }else{ UFE.StartIntroScreen(0f); } }