using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class fullscreen : MonoBehaviour, IVirtualButtonEventHandler
{
private GameObject vbButtonObject;
// Use this for initialization
void Start()
{
vbButtonObject = GameObject.Find("fullb");
vbButtonObject.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);
}
public void OnButtonPressed(VirtualButtonBehaviour vb)
{
Debug.Log("1");
}
public void OnButtonReleased(VirtualButtonBehaviour vb)
{
Debug.Log("2");
}
// Update is called once per frame
void Update()
{
}
}
This is my codes for a project when I try VirtualButtonAbstractBehaviour instead of VirtualButtonBehaviour it's underlining it like there is a typo. My virtual button not working please help.
Just make sure the AR camera is on the image target It works for me !!!
enter image description here
Related
I need to just show a message (Under certain circumstance) when I'm leaving a screen.
Found that there's a method called OnDisappearing() that is called when the form is being unloaded (Or also being overlaped by a new one).
What I found:
https://forums.xamarin.com/discussion/89563/intercept-page-leaving-event
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.page.ondisappearing?view=xamarin-forms
Issue is that if I just copy the code as it is I get an error cause of the override (no suitable method found to override) that won't let me leave the code as is:
*Same happens with OnBackButtonPressed()
Modified it and just left it without the override and it just won't be called by any mean..
protected void OnDisappearing()
{
Exiting();
}
private async void Exiting()
{
System.Threading.Tasks.Task tmpShouldExit = Application.Current.MainPage.DisplayAlert("Hello", "Hi", "OK");
}
Is something I'm missing?
Is there any other method I can use?
Thanks
As Jason made me notice.
I was placing this in the ViewModel and it has to be in the code of the View cause you're overriding a Method of the Page.
Then if you want to access a method of the ViewModel from the view you can create a BindingContext to do so:
using MyProject.PageModels;
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace MyProject.Pages
{
public partial class MyViewPage : ContentPage
{
public MyViewPage()
{
InitializeComponent();
NavigationPage.SetBackButtonTitle(this, string.Empty);
}
protected override void OnDisappearing()
{
base.OnDisappearing();
var pageViewModel = (MyViewModel)this.BindingContext;
if(pageViewModel.CertainConditionShowAlert())
{
System.Threading.Tasks.Task tmpShouldExit = Application.Current.MainPage.DisplayAlert("Hi", "Hello", "OK");
}
}
}
}
Hello, i have been working on this problem for 3 days and i cant figure out what is wrong with it. The error message i got is "SpawnObject for Player(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server." i know that the server is starting fine because when i connect to it with a client then close the server the client says that the server may have shutdown. Here is the code i have so far. THANK YOU IN ADVANCE
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Collections;
public class MENU_CONTROLLER : NetworkBehaviour
{
public GameObject ipField;
public GameObject connectButton;
public GameObject hostButton;
public GameObject player;
public Text ip;
public Text PlayerCount;
private int playercount = 0;
void Update() {
}
void vanishMenu() {
ipField.SetActive(false);
connectButton.SetActive(false);
hostButton.SetActive(false);
}
public void ServerConnect() {
Network.Connect(ip.text.ToString(), 4444);
vanishMenu();
SpawnPlayer();
}
public void SpawnPlayer() {
GameObject p = (GameObject)Instantiate(player, transform.position,transform.rotation);
NetworkServer.Spawn(p);
}
public void ServerStart() {
Network.InitializeServer(30, 4444, true);
Network.Connect("localhost", 4444);
SpawnPlayer();
}
void OnPlayerConnected(NetworkPlayer player) {
playercount++;
print("PLAYER CONNECTED");
print(player.ipAddress);
PlayerCount.text = playercount.ToString();
}
}
You must call the NetworkServer.Spawn() from within an "is server" block.
if (is Server) {
//do your thing to spawn
}
I would like to use CommandButton on a devexpress form. I set the .glyph to a large image. Then I set the PaintStyle (only way I found to show the caption too) to CaptionGlyph value. It places the caption next to the Icon. How can I place it below the Icon (see left one as a LargeButton).
I needed only the .command from the CommandButton, so I decided to make a new component from an existing one: BarLargeButtonItem with implementation of ISupportReportCommand. Only problem with this, that I can put this on the form only by modifying the .designer.cs file, what is lamme, but works.
Here is the code in case someone else will need such thing:
using DevExpress.XtraBars;
using DevExpress.XtraReports.UserDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StefaniaNET.Nyomtatvanyok.Komponensek
{
public class Gomb : BarLargeButtonItem, ISupportReportCommand
{
public Gomb()
{
#region alapbeállítások
PaintStyle = BarItemPaintStyle.CaptionGlyph;
CaptionAlignment = BarItemCaptionAlignment.Bottom;
#endregion
}
#region ISupportReportCommand implementáció
public ReportCommand Command { get; set; }
//public ReportCommand Command
//{
// get { throw new NotImplementedException(); }
//}
#endregion
}
}
So here's my predicament. I'm writing a custom, one-off content management system, and I can not for the life of me getting this method to work correctly. What I want to do is create a laundry list worth of methods in separate folders and call them as I need them on whichever web forms I want to call them on.
I created a WebApp and created a folder inside of the app called App_Code. Inside of App_Code, there is a public class called "TestimonialService". Here it is:
/******************** TESTIMONIAL SERVICE ****************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlueTreeSecurity.App_Code.Data;
namespace BlueTreeSecurity.App_Code.Testimonials
{
public class TestimonialService
{
private readonly CMSObjectContext _context;
public TestimonialService(CMSObjectContext context)
{
this._context = context;
}
#region methods
/// <summary>
/// Gets all testimonials
/// </summary>
/// <returns>testimonial collection</returns>
public List<Testimonial> GetAllTestimonials()
{
var query = from t in _context.Testimonials
orderby t.DisplayOrder ascending
select t;
if (query.Count() > 0)
{
var testimonial = query.ToList();
return testimonial;
}
else
{
return null;
}
}
#endregion
}
}
Then on the actual aspx.cs page I call said function like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BlueTreeSecurity.App_Code;
using BlueTreeSecurity.App_Code.Data;
using BlueTreeSecurity.App_Code.Testimonials;
namespace BlueTreeSecurity
{
public partial class Testimonials : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Page.Title = "Testimonials | ...";
Bind_Data();
}
protected void Bind_Data()
{
/** when i try to use intellisense here it's not recognized. **/
var testimonials = TestimonialService.GetAllTestimonials();
rptTestimonials.DataSource = testimonials;
rptTestimonials.DataBind();
}
}
}
The exact error spat back is this:
Error 1
An object reference is required for the non-static field, method, or property
'BlueTreeSecurity.App_Code.Testimonials.TestimonialService.GetAllTestimonials()'
Anything would be appreciated, guys. I'm ripping my hair out here.
Here's the Project structure
- Blue Tree Security (main project)
- App_Code
+ Data
+ Testimonials
+ TestimonialService.cs
Rest of the .aspx, .aspx.cs, and .ascx files.
If i'm not totally misinterpreting here, the error message you are getting is telling you what the problem is. Make GetAllTestimonials() static or instantiate a TestimonialService instance.
protected void Bind_Data()
{
var testimonialService = new TestimonialService(yourContextObect);
var testimonials = testimonialService.GetAllTestimonials();
rptTestimonials.DataSource = testimonials;
rptTestimonials.DataBind();
}
I'm trying build out our logging framework using EntLib Logging and use attribute to indicate which class/method should be logged. So I think Interception would be a good choice. I'm a super noob to Ninject and Interception and I's following the tutorial at Innovatian Software on how to use interception via attributes. But when I run the app, BeforeInvoke and AfterInvoke was never called. Help Please, Thank You!
using System;
using System.Diagnostics;
using System.Collections.Generic;
using Castle.Core;
using Ninject;
using Ninject.Extensions.Interception;
using Ninject.Extensions.Interception.Attributes;
using Ninject.Extensions.Interception.Request;
class Program
{
static void Main(string[] args)
{
var kernel = new StandardKernel();
kernel.Bind<ObjectWithMethodInterceptor>().ToSelf();
var test= kernel.Get<ObjectWithMethodInterceptor>();
test.Foo();
test.Bar();
Console.ReadLine();
}
}
public class TraceLogAttribute : InterceptAttribute
{
public override IInterceptor CreateInterceptor(IProxyRequest request)
{
return request.Context.Kernel.Get<TimingInterceptor>();
}
}
public class TimingInterceptor : SimpleInterceptor
{
readonly Stopwatch _stopwatch = new Stopwatch();
protected override void BeforeInvoke(IInvocation invocation)
{
Console.WriteLine("Before Invoke");
_stopwatch.Start();
}
protected override void AfterInvoke(IInvocation invocation)
{
Console.WriteLine("After Invoke");
_stopwatch.Stop();
string message = string.Format("Execution of {0} took {1}.",
invocation.Request.Method,
_stopwatch.Elapsed);
Console.WriteLine(message);
_stopwatch.Reset();
}
}
public class ObjectWithMethodInterceptor
{
[TraceLog] // intercepted
public virtual void Foo()
{
Console.WriteLine("Foo - User Code");
}
// not intercepted
public virtual void Bar()
{
Console.WriteLine("Bar - User Code");
}
}
I figured it out, I missed the part where I've to disable auto module loading and manually load the DynamicProxy2Module to the kernel. Here's the change to the code:
//var kernel = new StandardKernel(); //Automatic Module Loading doesn't work
var kernel = new StandardKernel(new NinjectSettings() { LoadExtensions = false }, new DynamicProxy2Module());
Hope this help someone else.