Esempio n. 1
0
        public static void ShowWindow(GameObject gameObject, List <ModelProperties> gamelist)
        {
            modelSetup = gameObject.GetComponent <ModelSetup>();
            gameList   = gamelist.OrderBy(x => x.descriptiveName).ToList();
            EditorWindow window = GetWindow(typeof(EditorModelSetupGame)) as EditorModelSetupGame;

            window.Show();
        }
        private bool activateGraphics = true; // When Update() is used we need to activate graphics there so unityGraphics.TextureUpdated is at least once true

        void Start()
        {
            modelSetup = gameObject.GetComponent <ModelSetup>();
            if (modelSetup == null)
            {
                print("Error - no modelsetup found for " + gameObject.name);
            }
        }
Esempio n. 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ArcadeAttribute arcadeAttribute = attribute as ArcadeAttribute;

            position.width = position.width - arcadeAttribute.width - 16;
            EditorGUI.PropertyField(position, property, label);
            position.x     = position.x + position.width;
            position.width = arcadeAttribute.width + 16;

            if (GUI.Button(position, arcadeAttribute.label))
            {
                ModelSetup obj = property.serializedObject.targetObject as ModelSetup;
                //  if (obj == null) { return; }
                //Debug.Log("I belong to " + obj.descriptiveName);
                if (arcadeAttribute.label == "Model")
                {
                    EditorModelSetupSelectModel.ShowWindow(obj.transform.gameObject);
                }
                if (arcadeAttribute.label == "Emulator")
                {
                    if (ArcadeManager.emulatorsConfigurationList.Count < 1)
                    {
                        if (!ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulatorsConfigurationList())
                        {
                            return;
                        }
                    }
                    EditorModelSetupEmulator.ShowWindow(obj.transform.gameObject);
                }
                if (arcadeAttribute.label == "Game")
                {
                    EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(obj.emulator);
                    if (emulatorConfiguration != null)
                    {
                        List <ModelProperties> gamelist = emulatorConfiguration.masterGamelist;
                        EditorModelSetupGame.ShowWindow(obj.transform.gameObject, gamelist);
                    }
                }
                if (arcadeAttribute.label == "Folder")
                {
                    string folder = FileManager.DialogGetFolderPath(true);
                    if (folder != null)
                    {
                        property.stringValue = folder;
                    }
                }
                if (arcadeAttribute.label == "Exe")
                {
                    string exe = FileManager.DialogGetFilePart("Select LibretroCore Executable", null, FileManager.FilePart.Name_Extension);
                    if (exe != null)
                    {
                        property.stringValue = exe;
                    }
                }
            }
        }
Esempio n. 4
0
        public static void ShowWindow(GameObject gameObject, string assetPath, string assetName)
        {
            Debug.Log("show me now");
            BuildAssetBundleWindow.assetPath = assetPath;
            BuildAssetBundleWindow.assetName = assetName;
            modelSetup = gameObject.GetComponent <ModelSetup>();
            EditorWindow window = GetWindow(typeof(BuildAssetBundleWindow)) as BuildAssetBundleWindow;

            window.Show();
        }
Esempio n. 5
0
        private bool IsInView(GameObject toCheck)
        {
            if (distance > maxDistance)
            {
                return(false);
            }
            return(true);

            Vector3 pointOnScreen = thisCamera.WorldToScreenPoint(toCheck.GetComponentInChildren <Renderer>().bounds.center);

            //if (arcadeLayer) { Debug.Log("check: " + modelProperties.id); }

            //Is in front
            if (pointOnScreen.z < 0)
            {
                //if (arcadeLayer) { Debug.Log("checknotinfront: " + modelProperties.id); }
                //return false;
            }

            //Is in FOV
            if (arcadeLayer)
            {
                if ((pointOnScreen.x < 0) || (pointOnScreen.x > Screen.width) ||
                    (pointOnScreen.y < 0) || (pointOnScreen.y > Screen.height))
                {
                    if (arcadeLayer)
                    {
                        Debug.Log("checkOutOfBounds: " + modelProperties.id);
                    }
                    //return false;
                }
            }

            RaycastHit hit;

            // Vector3 heading = toCheck.transform.position - thisCamera.transform.position;
            // Vector3 direction = heading.normalized;// / heading.magnitude;
            if (Physics.Linecast(thisCamera.transform.position, toCheck.GetComponentInChildren <Renderer>().bounds.center, out hit, layerMask))
            {
                ModelSetup hitModelSetup = hit.transform.parent.gameObject.GetComponent <ModelSetup>();
                if (hitModelSetup == null)
                {
                    return(false);
                }
                // Debug.LogError(modelProperties.id + " occluded by " + hitModelSetup.id);
                if (modelProperties.id == hitModelSetup.id)
                {
                    return(true);
                }
                //  Debug.DrawLine(Camera.main.transform.position, toCheck.GetComponentInChildren<Renderer>().bounds.center, Color.red);
                //  Debug.LogError(modelSetup.id + " occluded by " + hitModelSetup.id);
                return(false);
            }
            return(true);
        }
Esempio n. 6
0
        private void ActionGetArtworkFromSelectedModel(GameObject targetObjectParent)
        {
            if (ArcadeStateManager.selectedModelSetup == null || !(Application.isPlaying) || !(targetObjectParent.activeSelf))
            {
                return;
            }
            ModelProperties       modelProperties       = ArcadeStateManager.selectedModelSetup.GetModelProperties();
            ModelSharedProperties modelSharedProperties = ArcadeStateManager.selectedModelSetup.modelSharedProperties;
            ModelSetup            objModelSetup         = targetObjectParent.GetComponent <ModelSetup>();

            if (objModelSetup != null)
            {
                targetObjectParent.tag = "gamemodel";
                objModelSetup.Setup(modelProperties, modelSharedProperties);
            }
        }
Esempio n. 7
0
        public static void Setup(ArcadeType arcadeType)
        {
            string            type            = arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.CylArcade || arcadeType == ArcadeType.None ? "Arcade/" : "Menu/";
            List <ModelSetup> tempModelSetups = new List <ModelSetup>();


            GameObject obj = GameObject.Find(type + "ArcadeModels");

            if (obj != null)
            {
                AddFromParent(obj);
            }
            obj = GameObject.Find(type + "GameModels");
            if (obj != null)
            {
                AddFromParent(obj);
            }
            obj = GameObject.Find(type + "PropModels");
            if (obj != null)
            {
                AddFromParent(obj);
            }

            foreach (ModelSetup modelSetup in tempModelSetups)
            {
                Add(modelSetup, arcadeType);
            }
            modelSetups.AddRange(tempModelSetups);
            modelSetups.RemoveAll(x => x == null);

            void AddFromParent(GameObject objParent)
            {
                var transform = objParent.transform;

                for (int i = transform.childCount - 1; i >= 0; --i)
                {
                    ModelSetup modelSetup = objParent.transform.GetChild(i).gameObject.GetComponent <ModelSetup>();
                    if (modelSetup != null)
                    {
                        tempModelSetups.Add(modelSetup);
                    }
                }
            }
        }
Esempio n. 8
0
 private void OnEnable()
 {
     ModelSetupScript = target as ModelSetup;
 }
        public void ResetMenu()
        {
            // Destroy the models attached to the camera
            GameObject        tobj        = ArcadeManager.arcadeCameras[ArcadeType.CylMenu].transform.gameObject;
            List <GameObject> gameObjects = tobj.GetChildren();

            foreach (GameObject child in gameObjects)
            {
                ModelSetup modelSetup = child.GetComponent <ModelSetup>();
                if (modelSetup != null)
                {
                    DestroyModel(child);
                }
            }

            var obj = GameObject.Find("Menu/GameModels");

            if (obj == null)
            {
                Debug.Log("no game models found");
                return;
            }
            var transform = obj.transform;

            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();

            obj = GameObject.Find("Menu/ArcadeModels");
            if (obj == null)
            {
                Debug.Log("no arcade models found");
                return;
            }
            transform = obj.transform;
            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();

            obj = GameObject.Find("Menu/PropModels");
            if (obj == null)
            {
                Debug.Log("no prop models found");
                return;
            }
            transform = obj.transform;
            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();
            void DestroyModel(GameObject child)
            {
                if (Application.isPlaying)
                {
                    Object.Destroy(child);
                }
                else
                {
                    Object.DestroyImmediate(child);
                }
            }
        }
        public void ResetArcade()
        {
            TriggerManager.SendEvent(Event.ArcadeEnded);
            TriggerManager.triggersActive = new Dictionary <Event, List <ModelTriggerSetup> >();

            ResetMenu();

            // Destroy the models attached to the camera
            GameObject        tobj        = ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].transform.gameObject;
            List <GameObject> gameObjects = tobj.GetChildren();

            foreach (GameObject child in gameObjects)
            {
                ModelSetup modelSetup = child.GetComponent <ModelSetup>();
                if (modelSetup != null)
                {
                    DestroyModel(child);
                }
            }

            // Reset external assets.
            AssetBundle.UnloadAllAssetBundles(true);
            ArcadeManager.modelAssets.Clear();
            GameObject obj = GameObject.Find("EditorModelCache");

            if (obj != null)
            {
                foreach (Transform child in obj.transform)
                {
                    DestroyModel(child.gameObject);
                }
                DestroyModel(obj);
            }

            obj = GameObject.Find("Arcade/GameModels");
            if (obj == null)
            {
                Debug.Log("no game models found");
                return;
            }
            var transform = obj.transform;

            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();

            obj = GameObject.Find("Arcade/ArcadeModels");
            if (obj == null)
            {
                Debug.Log("no arcade models found");
                return;
            }
            transform = obj.transform;
            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();

            obj = GameObject.Find("Arcade/PropModels");
            if (obj == null)
            {
                Debug.Log("no prop models found");
                return;
            }
            transform = obj.transform;
            for (int i = transform.childCount - 1; i >= 0; --i)
            {
                DestroyModel(transform.GetChild(i).gameObject);
            }
            transform.DetachChildren();
            void DestroyModel(GameObject child)
            {
                if (Application.isPlaying)
                {
                    Object.Destroy(child);
                }
                else
                {
                    Object.DestroyImmediate(child);
                }
            }

            Resources.UnloadUnusedAssets();
            TriggerManager.UnLoadTriggers();
        }
        public GameObject AddModelToArcade(ModelType modelType, ModelProperties modelProperties, ArcadeType arcadeType, bool addTrigger)
        {
            AssetBundle tAsset;
            GameObject  tObj;

            tAsset = GetExternalModel(modelProperties.model);
            if (tAsset != null)
            {
                return(addExternalModel(tAsset));
            }
            tObj = GetInternalModel(modelProperties.model);
            if (tObj != null)
            {
                return(AddInternalModel(tObj));
            }
            tAsset = GetExternalModel(modelProperties.id);
            if (tAsset != null)
            {
                return(addExternalModel(tAsset));
            }
            tObj = GetInternalModel(modelProperties.id);
            if (tObj != null)
            {
                return(AddInternalModel(tObj));
            }
            tAsset = GetExternalModel(modelProperties.idParent);
            if (tAsset != null)
            {
                return(addExternalModel(tAsset));
            }
            tObj = GetInternalModel(modelProperties.idParent);
            if (tObj != null)
            {
                return(AddInternalModel(tObj));
            }

            // Now check for defaultmodels
            // First defaultmodel filters in the emulator
            List <EmulatorConfiguration> emulatorConfiguration = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == modelProperties.emulator).ToList();

            if (emulatorConfiguration.Count > 1)
            {
                List <DefaultModelFilter> defaultModelFilters = emulatorConfiguration[0].emulator.defaultModelFilters;
                foreach (DefaultModelFilter defaultModel in defaultModelFilters)
                {
                    bool success = true;
                    foreach (ModelFilter filter in defaultModel.modelFilters)
                    {
                        success &= FilterModel(filter, modelProperties);
                    }
                    if (success)
                    {
                        tAsset = GetExternalModel(defaultModel.model);
                        if (tAsset != null)
                        {
                            return(addExternalModel(tAsset));
                        }
                        tObj = GetInternalModel(defaultModel.model);
                        if (tObj != null)
                        {
                            return(AddInternalModel(tObj));
                        }
                    }
                }
            }

            // Generic defaultmodel filters
            if (arcadeManager.generalConfiguration != null)
            {
                List <DefaultModelFilter> defaultModelFilters = arcadeManager.generalConfiguration.defaultModelFilters;
                foreach (DefaultModelFilter defaultModel in defaultModelFilters)
                {
                    bool success = true;
                    foreach (ModelFilter filter in defaultModel.modelFilters)
                    {
                        success &= FilterModel(filter, modelProperties);
                    }
                    if (success)
                    {
                        tAsset = GetExternalModel(defaultModel.model);
                        if (tAsset != null)
                        {
                            return(addExternalModel(tAsset));
                        }
                        tObj = GetInternalModel(defaultModel.model);
                        if (tObj != null)
                        {
                            return(AddInternalModel(tObj));
                        }
                    }
                }
            }

            // defaultmodel
            string[]      defaultModels = { "default70hor", "default70vert", "default80hor", "default80vert", "default90hor", "default90vert" };
            System.Random rnd           = new System.Random();
            tObj = GetInternalModel(defaultModels[rnd.Next(defaultModels.Length)]);
            if (tObj != null)
            {
                return(AddInternalModel(tObj));
            }

            return(null);

            AssetBundle GetExternalModel(string modelName)
            {
                List <AssetBundle> prefab = ArcadeManager.modelAssets.Where(x => x.name == modelName).ToList();

                if (prefab.Count < 1)
                {
                    var file = FileManager.FileExists(ArcadeManager.applicationPath + "/3darcade~/Configuration/Assets/" + ArcadeManager.currentOS.ToString() + "/" + modelType.ToString() + "s/", modelName + ".unity3d");
                    if (file != null)
                    {
                        var asset = AssetBundle.LoadFromFile(file);
                        if (asset != null && asset.name != null && asset.name != "")
                        {
                            ArcadeManager.modelAssets.Add(asset);
                            prefab.Add(asset);
                            return(asset);
                        }
                    }
                }
                return(prefab.Count == 1 ? prefab[0] : null);
            }

            GameObject addExternalModel(AssetBundle asset)
            {
                GameObject me    = asset.LoadAsset(asset.name) as GameObject;
                GameObject child = UnityEngine.Object.Instantiate(me);

                return(AddModel(child, modelProperties));
            }

            GameObject GetInternalModel(string modelName)
            {
                GameObject obj = (UnityEngine.GameObject)Resources.Load(modelType.ToString() + "s/" + modelName, typeof(GameObject));

                // TODO: NBNB remove this hack to be able to use gamelist models as prop models
                if (obj == null)
                {
                    obj = (UnityEngine.GameObject)Resources.Load(ModelType.Game.ToString() + "s/" + modelName, typeof(GameObject));
                }
                return(obj == null ? null : obj);
            }

            GameObject AddInternalModel(GameObject obj)
            {
                GameObject child = UnityEngine.Object.Instantiate(obj);

                return(AddModel(child, modelProperties));
            }

            GameObject AddModel(GameObject obj, ModelProperties model)
            {
                GameObject dummyNode;

                if (Application.isPlaying)
                {
                    dummyNode = new GameObject("dummy");
                    obj.transform.SetParent(dummyNode.transform);
                }
                else
                {
                    dummyNode = obj;
                }

                var modelSetup = dummyNode.GetComponent <ModelSetup>();

                if (modelSetup == null)
                {
                    dummyNode.AddComponent <ModelSetup>();
                    modelSetup = dummyNode.GetComponent <ModelSetup>();
                }
                //Rigidbody rigidbody = obj.GetComponent<Rigidbody>();
                //if (rigidbody != null)
                //{
                //    rigidbody.isKinematic = true;
                //}
                dummyNode.transform.position   = model.position; // model is redundant you aleady have access to modelProperties
                dummyNode.transform.rotation   = model.rotation;
                dummyNode.transform.localScale = model.scale;
                if (modelType == ModelType.Arcade)
                {
                    dummyNode.tag = "arcademodel";
                }
                if (modelType == ModelType.Game)
                {
                    dummyNode.tag = "gamemodel";
                }
                if (modelType == ModelType.Prop)
                {
                    dummyNode.tag = "propmodel";
                }
                bool   isArcadeLayer = arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.CylArcade || arcadeType == ArcadeType.None ? true : false;
                string layer         = (isArcadeLayer ? "Arcade/" : "Menu/") + modelType.ToString() + "Models";

                dummyNode.layer = LayerMask.NameToLayer(layer);
                dummyNode.RunOnChildrenRecursive(tChild => tChild.layer = LayerMask.NameToLayer(layer));

                GameObject node = null;

                if (isArcadeLayer)
                {
                    node = GameObject.Find("Arcade/" + modelType.ToString() + "Models");
                }
                else
                {
                    node = GameObject.Find("Menu/" + modelType.ToString() + "Models");
                }

                if (node != null)
                {
                    dummyNode.transform.SetParent(node.transform);
                }
                else
                {
                    Debug.Log("Error: Could not find the models parent node...");
                }

                // Zoning
                if (arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.FpsMenu)
                {
                    if (!ArcadeManager.visibleZones[arcadeType].ContainsKey(modelProperties.zone))
                    {
                        ArcadeManager.visibleZones[arcadeType][modelProperties.zone] = new List <GameObject>();
                    }

                    if (modelProperties.zone != 0)
                    {
                        ArcadeManager.visibleZones[arcadeType][modelProperties.zone].Add(dummyNode);
                    }
                    else
                    {
                        if (Physics.Raycast(dummyNode.transform.position, -dummyNode.transform.up, out RaycastHit vision, 100.0f))
                        {
                            GameObject objectHit = vision.transform.gameObject;
                            if (objectHit != null)
                            {
                                ModelSetup hitModelSetup = objectHit.transform.parent.gameObject.GetComponent <ModelSetup>();
                                if (hitModelSetup != null)
                                {
                                    //Debug.Log("zonemodel " + modelSetup.descriptiveName);
                                    ArcadeManager.visibleZones[arcadeType][hitModelSetup.zone].Add(dummyNode);
                                }
                            }
                        }
                    }
                }

                ArcadeConfiguration arcadeConfiguration = isArcadeLayer ? ArcadeManager.arcadeConfiguration : ArcadeManager.menuConfiguration;

                modelSetup.Setup(model, arcadeConfiguration.modelSharedProperties);
                if (addTrigger && modelSetup.triggers.Count > 0 && Application.isPlaying)
                {
                    TriggerManager.Add(modelSetup, arcadeType);
                }
                return(dummyNode);
            }
        }
Esempio n. 12
0
        public static bool Add(ModelSetup modelSetup, ArcadeType arcadeType)
        {
            Dictionary <Event, List <TriggerWrapper> > triggerEvents = new Dictionary <Event, List <TriggerWrapper> >();
            ModelTriggerSetup modelTriggerSetup = null;
            GameObject        obj = modelSetup.gameObject.transform.GetChild(0).gameObject; // Get the model from its dummy parent

            if (obj == null)
            {
                return(false);
            }

            if (modelSetup.triggers.Count > 0)
            {
                modelTriggerSetup = obj.GetComponent <ModelTriggerSetup>();

                if (modelTriggerSetup == null)
                {
                    modelTriggerSetup = obj.AddComponent <ModelTriggerSetup>();
                }
                else
                {
                    // We already setup the triggers for this model!
                    return(true);
                }

                foreach (Trigger trigger in modelSetup.triggers)
                {
                    TriggerWrapper triggerWrapper = new TriggerWrapper();
                    triggerWrapper.triggerSourceGameObjects = new List <GameObject>();
                    triggerWrapper.triggerTargetGameObjects = new List <GameObject>();
                    triggerWrapper.trigger = trigger;
                    foreach (string source in trigger.triggerSource)
                    {
                        if (source.Trim().ToLower() == "self")
                        {
                            triggerWrapper.triggerSourceGameObjects.Add(obj);
                        }
                        else if (source.Trim().ToLower() == "camera")
                        {
                            triggerWrapper.triggerSourceGameObjects.Add(ArcadeManager.arcadeControls[arcadeType]);
                        }
                        else
                        {
                            List <ModelSetup> modelSetupsWithTriggerSources = modelSetups.Where(x => x.triggerIDs.Contains(source)).ToList();
                            if (modelSetupsWithTriggerSources.Count > 0)
                            {
                                foreach (ModelSetup modelSetupWithTriggerSource in modelSetupsWithTriggerSources)
                                {
                                    if (modelSetupWithTriggerSource == null)
                                    {
                                        continue;
                                    }
                                    triggerWrapper.triggerSourceGameObjects.Add(modelSetupWithTriggerSource.gameObject.transform.GetChild(0).gameObject);
                                }
                            }
                            else
                            {
                                triggerWrapper.triggerSourceGameObjects.Add(obj);
                            }
                        }
                    }
                    if (triggerWrapper.triggerSourceGameObjects.Count < 1)
                    {
                        triggerWrapper.triggerSourceGameObjects.Add(ArcadeManager.arcadeControls[arcadeType]);
                    }
                    foreach (string target in trigger.triggerTarget)
                    {
                        if (target.Trim().ToLower() == "self")
                        {
                            triggerWrapper.triggerTargetGameObjects.Add(obj);
                        }
                        else if (target.Trim().ToLower() == "camera")
                        {
                            triggerWrapper.triggerTargetGameObjects.Add(ArcadeManager.arcadeControls[arcadeType]);
                        }
                        else
                        {
                            List <ModelSetup> modelSetupsWithTriggerTargets = modelSetups.Where(x => x.triggerIDs.Contains(target)).ToList();
                            if (modelSetupsWithTriggerTargets.Count > 0)
                            {
                                foreach (ModelSetup modelSetupWithTriggerTarget in modelSetupsWithTriggerTargets)
                                {
                                    if (modelSetupWithTriggerTarget == null)
                                    {
                                        continue;
                                    }
                                    triggerWrapper.triggerTargetGameObjects.Add(modelSetupWithTriggerTarget.gameObject.transform.GetChild(0).gameObject);
                                }
                            }
                            else
                            {
                                triggerWrapper.triggerTargetGameObjects.Add(obj);
                            }
                        }
                    }
                    if (triggerWrapper.triggerTargetGameObjects.Count < 1)
                    {
                        triggerWrapper.triggerTargetGameObjects.Add(obj);
                    }
                    Event triggerEvent;
                    if (System.Enum.TryParse(trigger.triggerEvent, true, out triggerEvent))
                    {
                        if (!triggerEvents.ContainsKey(triggerEvent))
                        {
                            triggerEvents[triggerEvent] = new List <TriggerWrapper>();
                        }
                        if (!triggersActive.ContainsKey(triggerEvent))
                        {
                            triggersActive[triggerEvent] = new List <ModelTriggerSetup>();
                        }
                        triggerEvents[triggerEvent].Add(triggerWrapper);
                        if (modelTriggerSetup != null && !triggersActive[triggerEvent].Contains(modelTriggerSetup))
                        {
                            triggersActive[triggerEvent].Add(modelTriggerSetup);
                        }
                    }
                }
                modelTriggerSetup.Setup(triggerEvents);
            }
            return(true);
        }
Esempio n. 13
0
        public static void LoadGame(ModelSetup game, ModelSetup selected)
        {
            TriggerManager.SendEvent(Event.GameStarted);

            selectedModelSetup = selected; // The model not its dummy node
            gameModelSetup     = game;     // Different from selected when game was choosen in CylMenu or FpsMenu.

            if (gameModelSetup == null)
            {
                UnityEngine.Debug.Log("Launcher: model setup not found");
                return;
            }
            else
            {
                UnityEngine.Debug.Log("Launcher: launching " + gameModelSetup.id);
            }
            if (selectedModelSetup == null)
            {
                UnityEngine.Debug.Log("Launcher: selectedmodel setup not found");
                return;
            }
            else
            {
                UnityEngine.Debug.Log("Launcher: launchingselected " + selectedModelSetup.id);
            }
            List <EmulatorConfiguration> emulatorConfiguration = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == gameModelSetup.emulator).ToList();

            if (emulatorConfiguration.Count < 1)
            {
                UnityEngine.Debug.Log("Launcher: no emulator configuration found");
                return;
            }
            selectedModelSetup.isPlaying = true;
            var launcherMethod = GameLauncherMethod.None;

            launcherMethod = gameModelSetup.gameLauncherMethod;
            if (launcherMethod == GameLauncherMethod.None)
            {
                System.Enum.TryParse(emulatorConfiguration[0].emulator.gameLauncherMethod, true, out launcherMethod);
            }
            if (launcherMethod == GameLauncherMethod.None)
            {
                System.Enum.TryParse(selectedModelSetup == gameModelSetup ? ArcadeManager.arcadeConfiguration.gameLauncherMethod : ArcadeManager.menuConfiguration.gameLauncherMethod, true, out launcherMethod);
            }
            switch (launcherMethod)
            {
            case GameLauncherMethod.Internal:
                LoadInternalGame(emulatorConfiguration[0].emulator);
                break;

            case GameLauncherMethod.External:
                LoadExternalGame(emulatorConfiguration[0].emulator);
                break;

            case GameLauncherMethod.URL:
                LoadURLGame(emulatorConfiguration[0].emulator);
                break;

            default:
                UnityEngine.Debug.Log("Launcher: no launcher method found");
                break;
            }

            void LoadExternalGame(EmulatorProperties emulator)
            {
                // Application.OpenURL("mameios://");
                // TODO: Damn this works, but ugly! You know better!
                string path       = ArcadeManager.applicationPath;
                string executable = emulator.executable.Trim();
                string extension  = emulator.extension != null?emulator.extension.Trim() : "";

                // TODO: Implement commandline arguments
                //string arguments = emulator.arguments.Trim();
                string options      = emulator.options.TrimStart();
                string emulatorPath = FileManager.CorrectFilePath(emulator.emulatorPath);

                if (emulatorPath != "")
                {
                    emulatorPath = path + emulatorPath;
                }
                string gamePath = FileManager.CorrectFilePath(emulator.gamePath);

                if (gamePath != "")
                {
                    gamePath = path + gamePath;
                }
                string workingDir = FileManager.CorrectFilePath(emulator.workingDir);

                if (workingDir != "")
                {
                    workingDir = path + workingDir;
                }

                ProcessStartInfo startInfo = new ProcessStartInfo();

                startInfo.FileName  = emulatorPath + executable;
                startInfo.Arguments = options + gamePath + gameModelSetup.id.Trim() + extension; // space char after -File
                if (workingDir != "")
                {
                    startInfo.WorkingDirectory = workingDir;
                }
                startInfo.WindowStyle     = ProcessWindowStyle.Hidden;
                startInfo.CreateNoWindow  = true;
                startInfo.UseShellExecute = false;
                bool    started = false;
                Process process = new Process();

                process.StartInfo = startInfo;
                started           = process.Start();
                try
                {
                    int procId = process.Id;
                }
                catch (InvalidOperationException)
                {
                    started = false;
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.Log("Error: " + ex.Message + "  " + ex.InnerException);
                    started = false;
                }
                if (started)
                {
                    UnityEngine.Debug.Log("game started");
                    ArcadeManager.arcadeState = ArcadeStates.Game;
                }
            }

            void LoadInternalGame(EmulatorProperties emulator)
            {
                UnityEngine.Debug.Log("Launcher: start internal launcher " + selectedModelSetup.transform.gameObject.name);

                GameObject screen = selectedModelSetup.transform.GetChild(0).GetChild(1).gameObject;

                UnityEngine.Debug.Log("selected obj " + selectedModelSetup.name);
                ModelVideoSetup video = screen.GetComponent <ModelVideoSetup>();

                video.ReleasePlayer(false);
                UnityEngine.Debug.Log("selected video " + video);

                RigidbodyFirstPersonController arcadeRigidbodyFirstPersonController = ArcadeManager.arcadeControls[ArcadeType.FpsArcade].GetComponent <RigidbodyFirstPersonController>();

                if (arcadeRigidbodyFirstPersonController != null)
                {
                    arcadeRigidbodyFirstPersonController.pause = true;
                }

                // TODO: Damn this works, but ugly!
                string path       = ArcadeManager.applicationPath;
                string executable = emulator.libretroCore.Trim();
                string extension  = emulator.extension != null?emulator.extension.Trim() : "";

                string arguments    = emulator.arguments.Trim();
                string options      = emulator.options.TrimStart();
                string emulatorPath = FileManager.CorrectFilePath(emulator.emulatorPath);

                if (emulatorPath != "")
                {
                    emulatorPath = Path.Combine(path + emulatorPath);
                }
                string gamePath = FileManager.CorrectFilePath(emulator.gamePath);

                if (gamePath != "")
                {
                    gamePath = Path.Combine(path + gamePath);
                }
                string workingDir = FileManager.CorrectFilePath(emulator.workingDir);

                if (workingDir != "")
                {
                    workingDir = Path.Combine(path + workingDir);
                }

                //UnityEngine.Debug.Log("is path" + gamePath );
                //UnityEngine.Debug.Log("is game" + gameModelSetup.id);
                ModelLibretroGameSetup libretroGame;

                libretroGame = selectedModelSetup.gameObject.GetComponent <ModelLibretroGameSetup>();
                if (libretroGame == null)
                {
                    libretroGame = selectedModelSetup.gameObject.AddComponent <ModelLibretroGameSetup>();
                    modelLibretroGameSetupsList.Add(libretroGame);
                    libretroGame.StartGame(executable, gamePath, gameModelSetup.id);
                }
                else
                {
                    libretroGame.ResumeGame();
                }
                // Increase 1 to support more then one game at once
                if (modelLibretroGameSetupsList.Count > 1)
                {
                    libretroGame = modelLibretroGameSetupsList[0];
                    if (libretroGame != null)
                    {
                        libretroGame.StopGame();
                        modelLibretroGameSetupsList.RemoveAt(0);
                    }
                }
                ArcadeManager.arcadeState = ArcadeStates.Game;
            }

            void LoadURLGame(EmulatorProperties emulator)
            {
                Application.OpenURL(emulator.executable.Trim() + emulator.options.Trim() + gameModelSetup.id.Trim() + emulator.arguments.Trim());
                ArcadeManager.arcadeState = ArcadeStates.Game;
            }
        }