/// Creates an instance of the model referenced in item. private void OnItemSelected(ConstellationMenuItem item) { if (item.prefab == null) { return; } Vector3 laserEnd = laserPointer.MaxPointerEndPoint; // Calculate the intersection of the point with the head sphere. Vector3 headRight = Camera.main.transform.right; headRight.y = 0.0f; headRight.Normalize(); Vector3 cameraCenter = Camera.main.transform.position; Vector3 rayFromCamera = (laserEnd - cameraCenter).normalized; Vector3 up = Vector3.Cross(rayFromCamera, headRight); if (model != null) { Destroy(model); } model = Instantiate(item.prefab); model.transform.localScale = Vector3.zero; model.transform.position = laserEnd; model.transform.rotation = Quaternion.LookRotation(rayFromCamera, up) * defaultRotation; modelScale = new IconValue(0.0f); modelScale.FadeTo(1.0f, 0.25f, Time.time); }
private static Drawable GetIcon(Context context, IconValue icon) { return(With(context) .SetIcon(icon) .SetColor(Color.DarkGray) .SetToActionbarSize() .Build()); }
private void CheckTooMany(IconValue icon, int index, string dir) { lock (lockObject) { string html = GetHtmlString(icon.Url); if (html.IndexOf("TODAY, Too many download requests.") >= 0) { downContinual = false; this.CrossThreadDo(() => { fc = new frmIconCheck(); fc.Url = icon.Url; fc.Dir = dir; fc.FormClosed += fc_FormClosed; for (int i = 0; i < threadCount; i++) { if (i != index) { switch (th[i].ThreadState) { case System.Threading.ThreadState.WaitSleepJoin | System.Threading.ThreadState.Background: //线程LOCK时,直接停止 th[i].Abort(); break; case System.Threading.ThreadState.Running: //正在下载时,等待此次下载完成 th[i].Join(5000); break; default: this.txtShow.AppendText("错误的状态" + th[i].ThreadState.ToString()); this.txtShow.AppendText("\r\n"); break; } } } fc.Show(); th[index].Abort(); }); } } }
public static void SetIcon(this ImageButton button, IconValue icon) { button.SetImageDrawable(GetIcon(button.Context, icon)); }