Exemple #1
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            SimulatorWindow.MarkAllDeviceListsDirty();

            var asset = ScriptableObject.CreateInstance <DeviceInfoAsset>();

            var deviceJson = File.ReadAllText(ctx.assetPath);

            asset.deviceInfo = ParseDeviceInfo(deviceJson, out var errors, out var systemInfoElement, out var graphicsDataElement);

            if (errors.Length > 0)
            {
                asset.parseErrors = errors;
            }
            else
            {
                FindOptionalFieldAvailability(asset, systemInfoElement, graphicsDataElement);
                AddOptionalFields(asset.deviceInfo);

                // Saving asset path in order to find overlay relatively to it
                asset.directory = Path.GetDirectoryName(ctx.assetPath);
                ctx.DependsOnSourceAsset(ctx.assetPath);
            }

            ctx.AddObjectToAsset("main obj", asset);
            ctx.SetMainObject(asset);
        }
        public static SettingsProvider CreateDeviceSimulatorSettingsProvider()
        {
            var provider = new DeviceSimulatorProjectSettingsProvider("Project/Device Simulator", SettingsScope.Project);

            provider.activateHandler = (searchContext, rootElement) =>
            {
                var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("packages/com.unity.device-simulator/Editor/SimulatorResources/UXML/ui_project_settings.uxml");
                visualTree.CloneTree(rootElement);
                rootElement.Bind(provider.SerializedSettings);

                rootElement.Q <Toggle>("system-info-toggle").RegisterCallback <ChangeEvent <bool> >(evt => SimulatorWindow.RestartAllSimulators());
                rootElement.Q <Toggle>("application-toggle").RegisterCallback <ChangeEvent <bool> >(evt => SimulatorWindow.RestartAllSimulators());
                rootElement.Q <Toggle>("default-assembly-toggle").RegisterCallback <ChangeEvent <bool> >(evt => SimulatorWindow.RestartAllSimulators());
                var assemblyList = rootElement.Q <ListView>("assembly-list");
                assemblyList.RegisterCallback <ChangeEvent <int> >(evt => SimulatorWindow.RestartAllSimulators());
                assemblyList.RegisterCallback <ChangeEvent <string> >(evt => SimulatorWindow.RestartAllSimulators());
            };

            return(provider);
        }
        public static void ShowWindow()
        {
            SimulatorWindow window = GetWindow <SimulatorWindow>();

            window.Show();
        }