0
我有一个类用这种方法旋转立方体我的方法
rotire.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using System.Collections;
namespace WpfApplication3
{
class rotire:MonoBehaviour
{
float speed = 10f;
public void rotiree()
{
transform.Rotate(new Vector3(15,40,45)*speed,Time.deltaTime);
}
}
}
我想用这种方法来旋转立方体我在XAML中取得。
不幸的是,它不工作,我认为我的代码是不正常的。
请问,有人可以帮助我一个理想,我应该写什么。
窗口1,CS
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
rotire rot = new rotire();
rot.rotiree();
mycube.Transform = rot;
}
我相信代码的最后一行是错误的,因为我收到此错误
"Cannot implicitly convert type 'WpfApplication3.rotire' to 'System.Windows.Media.Media3D.Transform3D'"
另一个错误“不能隐式地将类型'UnityEngine.Transform'转换为'System.Windows.Media.Media3D.Transform3D” –
这是因为Unity转换与WPF转换不同。他们来自完全不同的系统并且是不同的类别。谷歌搜索如何转换他们之间没有任何结果,所以也许你应该在这里提出另一个具体的问题。或者,您也可以不使用Unity,只在项目中使用WPF。 – Jashaszun
你的意思是搜索或询问如何隐藏WPF(转换)到Unity(转换)? –