2014-07-22 58 views
-3

我得到的代碼的最後一行這個錯誤,不知道如何轉換如何轉換UnityEngine.Transform到Media3d.Transform3d

Cannot implicitly convert type 'UnityEngine.Transform' to 'System.Windows.Media.Media3D.Transform3D' 

這是代碼:

private void Window_Loaded_1(object sender, RoutedEventArgs e) 
    { 
     rotire rot = new rotire(); 
     rot.rotiree(); 
     mycube.Transform = rot.transform; 
    } 

這是方法:

public void rotiree() 
    { 
     transform.Rotate(new Vector3(15,40,45)*speed,Time.deltaTime); 
    } 

編輯: Rotire類包含一個方法旋轉的cube.The名方法是 「rotire」

多維數據集在XAML做出

rotire.cs

using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using UnityEngine; 
using System.Collections; 

namespace WpfApplication6 
{ 
    class Rotire:MonoBehaviour 
    { 
     float speed=10f; 
     public void rotire() 
     { 
      transform.Rotate(new Vector3(15,40,45)*speed,Time.deltaTime); 
     } 
    } 
} 
+3

什麼是「rotire」類(爲什麼它的名字以小寫字母開頭)?什麼是mycube類? 「轉換」成員是什麼類型? – MarioDS

回答

0

你瘋狂混合團結和WPF。我不認爲這是有意的。

在這裏,你創建一個對象基於統一MonoBehavior類:

rotire rot = new rotire(); 

這接縫是一個Media3d類:

mycube 

在這裏你嘗試引用統一轉換成Media3d .Transform(WPF變換)對象。

mycube.Transform = rot.transform; 

這不能工作,因爲它們不是相同的類型。您可能需要在WPF中旋轉WPF多維數據集或在Unity中旋轉Unity多維數據集。

+0

我想旋轉它在Unity(我的立方體XAML)。 我該怎麼做? –

+0

所以你想旋轉一個在xaml中定義的立方體。你想在Unity中做到這一點?我不認爲這是可能的。你可以在WPF中旋轉你的多維數據集http://stackoverflow.com/questions/12655033/rotate-3d-cube-in-wpf,或者你需要在Unity中創建一個多維數據集並在那裏旋轉它。 – EvilFonti