不知道GetComponent還需要宣告甚麼USING,我很多該宣和不該宣的都用了,還是無法解決。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEngine.UI;
using Vuforia;
using UnityEngine.SceneManagement;
using System.Data;
namespace script
{
public class Program
{
public static void Main(string[] args)
{
var position = SunPosition.CalculateSunPosition(DateTime.Now, latitude:515007, longitude:-01246);
Console.WriteLine("Result ==> Altitude {0}, Azimuth :{1}", position.Altitude, position.Azimuth);
double a = Math.Cos(position.Altitude) * Math.Sin(position.Azimuth);
double b = Math.Cos(position.Altitude) * Math.Cos(position.Azimuth);
double c = Math.Sin(position.Altitude);
GetComponent<Transform>().localPosition = new Vector3((float)a,(float)b, (float)c);
}
}
若你有真有這套件,且用法正確,使用VS的話,滑鼠移至GetComponent上,按ALT+ENTER,通常會提示你需要using什麼。
另外~
沒有物件就使用GetComponent,你確定使用方法是對的嗎?
我看起來有些怪~?
GetComponent<Transform>().localPosition = new Vector3((float)a,(float)b, (float)c);
沒有變數?還是你的localPosition左側的點是不小心按到的?
這樣試看看
GetComponent<Transform> localPosition = new Vector3((float)a,(float)b, (float)c);