使用Windows窗体应用程序在C中编译(Compile in C using a Windows Forms Application)
我正在使用Visual Studio 2010在C#中创建编译器应用程序。
该程序的目标是在运行时编译用C#或C编写的代码并返回编译结果。
我已经完成了C#部分,但C部分是我遇到的问题。 对于这个,我试图使用Visual Studio命令提示符。 我编写这部分的方式是这样的:
- 使用File.Create在C:\中创建.c文件。
- 使用进程,打开Visual Studio命令提示符并执行编译。
- 捕获输出以将其作为编译结果返回。
但是,它不起作用。 抛出和Win32异常,但我不知道为什么。
我听说过使用gcc的一些事情。 但我想过使用Visual Studio命令提示符作为可能的解决方案。
编辑:我想出了这样做的步骤(我想)。 但是当程序尝试执行process.Start()行时,会出现Win32异常。 我想这可能是一个权限问题,但我真的不知道。
I'm creating a compiler App in C#, using Visual Studio 2010.
The goal of this program is to compile a code written in either C# or C at runtime and return the results of the compilation.
I have done the C# part, but the C part is the one I have problems. For this one, I've tried to use the Visual Studio Command Prompt. The way I'm coding this part is like this:
- Create a .c file in C:\ using File.Create.
- Using a Process, open the Visual Studio Command Prompt and execute the compilation.
- Capture the output to return it as the compilation results.
However, it doesn't work. It throws and Win32 exception, but I don't really know why.
I've heard something about using gcc. But I thought about using the Visual Studio Command Prompt as a possible solution.
EDIT: I figured out the steps to do it (I think). But the Win32 exception appears when the program tries to do the process.Start() line. I guess this might be a permissions problem, but I don't really know.
原文:https://stackoverflow.com/questions/27199253
最满意答案
您需要根据球体移动方向移动相机位置 -
public GameObject player; private Vector3 offset; float distance; Vector3 playerPrevPos, playerMoveDir; // Use this for initialization void Start () { offset = transform.position - player.transform.position; distance = offset.magnitude; playerPrevPos = player.transform.position; } void LateUpdate () { playerMoveDir = player.transform.position - playerPrevPos; playerMoveDir.normalize(); transform.position = player.transform.position - playerMoveDir * distance; transform.LookAt(player.transform.position); playerPrevPos = player.transform.position; }
编辑2:要修复闪烁的相机,试试这个 -
void LateUpdate () { playerMoveDir = player.transform.position - playerPrevPos; if (playerMoveDir != Vector3.zero) { playerMoveDir.normalize(); transform.position = player.transform.position - playerMoveDir * distance; transform.position.y += 5f; // required height transform.LookAt(player.transform.position); playerPrevPos = player.transform.position; } }
You need to move your camera position based on sphere movement direction -
public GameObject player; private Vector3 offset; float distance; Vector3 playerPrevPos, playerMoveDir; // Use this for initialization void Start () { offset = transform.position - player.transform.position; distance = offset.magnitude; playerPrevPos = player.transform.position; } void LateUpdate () { playerMoveDir = player.transform.position - playerPrevPos; playerMoveDir.normalize(); transform.position = player.transform.position - playerMoveDir * distance; transform.LookAt(player.transform.position); playerPrevPos = player.transform.position; }
Edit 2: To fix flickering camera, try this -
void LateUpdate () { playerMoveDir = player.transform.position - playerPrevPos; if (playerMoveDir != Vector3.zero) { playerMoveDir.normalize(); transform.position = player.transform.position - playerMoveDir * distance; transform.position.y += 5f; // required height transform.LookAt(player.transform.position); playerPrevPos = player.transform.position; } }
相关问答
更多-
你可以在代码中做到这一点,例如 public class FullscreenByDefault : MonoBehaviour { void Start() { Screen.fullScreen = true; } } 或者在任何现有的MonoBehaviour You can do this in code, e.g. public class FullscreenByDefault : MonoBehaviour { void Start() ...
-
Unity3D播放器运动(Unity3D Player Movement)[2023-08-13]
C#区分大小写,因此如果这是您的确切代码,则永远不会调用您的函数。 它们需要被称为Start()和FixedUpdate() C# is case sensitive so if this is your exact code your functions will never be called. They need to be called Start() and FixedUpdate() -
请提供更多信息 请告诉我你使用的是哪种版本的统一? 您是否已将项目更新为其他最新版本的统一版? 同时给出“标签”数组的屏幕截图。 Please give us more information Please tell me which version of unity you are using? Have you updated the project to some other latest version of unity? Also give a screen shot of your 'tag' ...
-
您需要根据球体移动方向移动相机位置 - public GameObject player; private Vector3 offset; float distance; Vector3 playerPrevPos, playerMoveDir; // Use this for initialization void Start () { offset = transform.position - player.transform.position; distance = offset ...
-
Unity3D播放器移动脚本(Unity3D Player movement script)[2023-08-11]
每当我尝试只使用controller.Move()时,我的重力函数就会消失 这是文档中所述的预期行为: https : //docs.unity3d.com/ScriptReference/CharacterController.Move.html moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); 而不是从播放器获取输入,请指定您自己的moveDirection 。 例如: mov ... -
Android 4.1.2上的相机是黑色的Unity3D和Vuforia(Camera is black on Android 4.1.2 with Unity3D and Vuforia)[2022-03-09]
试试这段代码: public string deviceName; WebCamTexture wct; void Start () { WebCamDevice[] devices = WebCamTexture.devices; deviceName = devices[0].name; wct = new WebCamTexture(deviceName, 400, 300, 12); GetComponent().material.mainTex ... -
结合你的IF 你有最后和最大的支票...... currentDist = Vector3.Distance(transform.position,Player.position) if (currentDist
MaxTime) Destroy(th ... -
事实证明,问题是云上的构建版本。 构建设置为使用最新的5.5,但项目已升级到5.6。 将云构建更改为使用最新版本5.6后,构建成功 It turned out the issue was the build version on the cloud. The build was set to use the latest 5.5, but the project was upgraded to 5.6. After changing the cloud build to use Latest 5.6, th ...
-
Unity3D更改项目名称(Unity3D Change Project Name)[2023-03-12]
您是否尝试完全卸载您的应用并在重命名后重新安装,或者您只是尝试重新安装而不删除它? 因为它可以是android维护信息并使用旧的/第一个注册的密钥信息而不是刷新它们。 Did you tried uninstall completely your app and reinstall after rename it or you are just trying to reinstall without remove it? Because it could be android maintaining inf ... -
有几种方法可以实现这一点,但我建议使用Raycast。 我认为太阳不仅仅是一个点,它有一些区域可供玩家看到,所以即使他没有看到太阳的中心点,他仍然可以看到它的一部分区域。 如果是这样,我建议向sun对象添加一个新脚本,以便以编程方式识别它。 然后确保它的碰撞器组件的尺寸大约等于太阳。 然后在您想要检测玩家太阳能见度的脚本中,您可以执行以下操作: var ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (!Phy ...