why is GetComponent returning null?

As you can see in the attached image below and the code, I have added a class that implements the interface ICameraControl attached to a GameObject.

When I call var controller = GetComponent<ICameraControl>();, I get nothing returned (null), as in this example:

public class KeyboardHandler : MonoBehaviour {     private void Start()     {         var controller = GetComponent<ICameraControl>();         if (null == controller)             print("no ICameraControl found!");     }         } 

And the output is like this in the unity console:

no ICameraControl found! UnityEngine.MonoBehaviour:print(Object) Assets.Player.KeyboardHandler:Start() (at Assets/Player/KeyboardHandler.cs:18)

Here’s the Camera Position Handler attached to my game object: enter image description here

Here’s the interface implementation:

public class CameraPositionHandler : MonoBehaviour, ICameraControl {     private GameObject mainCamera;     private Quaternion homePosition;      private void Start()     {         mainCamera = GameObject.FindGameObjectWithTag("MainCamera");         homePosition = mainCamera.transform.rotation;     }      private void LateUpdate() { }  } 

Any ideas what I am doing wrong?

Much appreciated 🙂 Matt

Postgres index on IS NULL not working

CREATE TABLE tickets (   id bigserial primary key,   state character varying,   closed timestamp );  CREATE INDEX  "state_index" ON "tickets" ("state")   WHERE ((state)::text = 'open'::text)); 

A query with a condition on state performs well using an index scan as expected:

explain analyze select * from tickets where state = 'open';  Index Scan using state_index on tickets  (cost=0.29..16093.57 rows=36599 width=212) (actual time=0.025..22.875 rows=37346 loops=1) Planning time: 0.212 ms Execution time: 25.697 ms 

I am trying to achieve the same or better performance for the query:

explain analyze select * from tickets where closed IS NULL; 

However, none of the indexes I’ve tried result in a single index scan. Below are the indexes I’ve tried along with the EXPLAIN ANALYZE results.

A basic expression index:

CREATE INDEX  "closed_index" ON "tickets"  ((closed IS NULL))  explain analyze select * from tickets where closed IS NULL;  Seq Scan on tickets  (cost=0.00..45228.26 rows=36559 width=212) (actual time=0.025..271.418 rows=37348 loops=1)   Filter: (closed IS NULL)   Rows Removed by Filter: 836578 Planning time: 7.992 ms Execution time: 274.504 ms 

A basic partial index:

CREATE INDEX  "closed_index" ON "tickets"  ("closed") WHERE (closed IS NULL)  explain analyze select * from tickets where closed IS NULL;  Bitmap Heap Scan on tickets  (cost=604.22..38697.91 rows=36559 width=212) (actual time=12.879..48.780 rows=37348 loops=1)   Recheck Cond: (closed IS NULL)   Heap Blocks: exact=14757   ->  Bitmap Index Scan on closed_index  (cost=0.00..595.09 rows=36559 width=0) (actual time=7.585..7.585 rows=37348 loops=1) Planning time: 4.831 ms Execution time: 52.068 ms 

A partial expression index:

CREATE INDEX  "closed_index" ON "tickets" ((closed IS NULL))   WHERE (closed IS NULL);  explain analyze select * from tickets where closed IS NULL;  Bitmap Heap Scan on tickets  (cost=604.22..38697.91 rows=36559 width=212) (actual time=177.109..238.008 rows=37348 loops=1)   Recheck Cond: (closed IS NULL)   Heap Blocks: exact=14757   ->  Bitmap Index Scan on "closed_index"  (cost=0.00..595.09 rows=36559 width=0) (actual time=174.598..174.598 rows=37348 loops=1) Planning time: 23.063 ms Execution time: 241.292 ms 

Uncaught TypeError: Cannot read property ‘cancelPopUp’ of null in sharepoint hosted app

I referred the following link https://alinimer.wordpress.com/2013/02/25/open-pages-and-forms-in-modal-dialog-for-sharepoint-2013 to create a modal pop up .

I am able to create a pop up for the new form on button click with all the sharepoint list items as required. But after filling the values , on clicking Cancel button , I get an error in the console Cannot read property ‘cancelPopUp’ of null and the pop up window does not close on clicking cancel. Also on clicking the save button , the pop up does not close.

Can anyone please help on this?

Get first non null object, non empty string field value from a list

I have a

List<ClassA> listOfClassA; 

ClassA contains another object let say insideObj. I want to fetch the first instance of insideObj which is non null, and contains a non empty field which is a string. Currently i am doing

for (ClassA objA : listOfClassA) {         if(objA.getInsideObj() != null && !objA.getInsideObj().getName().isEmpty())             return objA.getInsideObj().getName();     } 

Is there a cleaner way to do this in Java 8?

Value cannot be null. Parameter name: fileOrServerOrConnection

I have a web part for Project Server 2013 that was developed by a colleague that’s no longer in the company, and I need to support it. When I try to add the web part to a page I get the following error:

error from SharePoint

Deploying it from Visual Studio is successful because I can see the web part added using Get-SPSolution in the Powershell, but no errors show in the VS output window, and there was nothing in the Event Viewer.

I searched the entire code for the string “fileOrServerOrConnection”, but I found nothing.

I have to admit I’m completely at a loss here because I have no idea how to investigate this problem.

Any suggestions at all? I don’t expect a full answer to the problem, but at least some help on how to proceed the investigation would be very much appreciatted.

Firebase Realtime DB – snapshot/query returning null for ObserveSingleEventOfType

I’m working on an iOS app and Firebase is generally working fine except in one case – I use remote push notifications, and when the users taps on one it’s supposed to open up a certain view and then makes a call to firebase to get the new data (that triggered the push notification). The problem is, for some reason the snapshot is always null in this scenario – I’ve printed out the url of the snapshot and can see that the data exists in the console – it works fine if I try to access it normally in the app, but not when the push notification tap to open the app happens. I’m assuming this may have something to do with background mode throwing off firebase. Has anyone encountered this before? My code is below:

       FIRDatabaseReference *ref = [[[FIRDatabase database] reference] child:@"test"];         [ref keepSynced:YES];          [[[ref2 child:self.val1] child:self.val2] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {             if (snapshot.exists) {                //Do app logic, reload the tableview...             }             } withCancelBlock:^(NSError * _Nonnull error) {                 NSLog(@"%@", error.localizedDescription);             }]; 

The ‘self.val1’ and ‘self.val2’ properties are passed to the view controller on the segue that occurs when the user opens the push notification.

Any tips appreciated, thanks!

Null and alternative Variables

My task for the 2 following problems is to identify the null value and alternative value:

Question 1: Perform hypothesis test for population proportion

It is known that 29% of the months have rice production by Company1 above 307200 cwt (company1>307200.0). Is there sufficient evidence to suggest that the proportion is less than 29%? Test at 5% level of significance.

My answer:

Null = .29

alternative = .01

Question 2: Perform hypothesis test for population mean

It is claimed that average rice production by Company2 is 209,500 cwt (Company2 = 209500.0). Test this claim using a hypothesis test at 1% level of significance.

My answer:

Null = 209500.0

alternative = .01

I’m being told that these my answers are not correct. I have no idea why. Any help would be appreciated!

C# method error Get returned null

I have written a method used in an ASP.NET 4.5 application as follows:

private SignupRequest BuildSignUpResult()     {         UserInfo objUser = new UserInfo();         int userId = objUser.UserId;         DotNetNuke.Entities.Users.UserInfo oUserInfo =             UserController.GetUserById(GatewayProvider_ProPay.portalId, userId);           var signupRequest = new SignupRequest         {             PersonalData =             {//removed for brevity},             Address =             {//removed for brevity },             AccountData =             {                 //removed for brevity             },             BankAccount =             {                 //removed for brevity             },             CardData =             {                 //removed for brevity             },             FraudDetector =             {                //removed for brevity              },             GrossBillingInfo =             {// removed for brevity },             MailAddress =             { // removed for brevity };         return signupRequest;     } 

When I attached the Visual Studio debugger to the process, I receive the error SignupRequest.PersonalData.**get** returned null.

My PersonalData object contains the following:

public ProPayPersonalData PersonalData     {         get { return _personalData; }         set { _personalData = value; }     } 

The ProPayPersonalData object is defined as:

 public class ProPayPersonalData {     private string _email;     private string _firstName;     private string _middleInitial;     private string _lastName;     private string _dateOfBirth;     private string _socialSecurityNumber;      public string Email     {         get { return _email;}         set { _email = value; }     }     public string FirstName     {         get { return _firstName; }         set { _firstName = value; }     }      public string MiddleInitial     {         get { return _middleInitial; }         set { _middleInitial = value; }     }      public string LastName     {         get { return _lastName; }         set { _lastName = value; }     }      public string DateOfBirth     {         get { return _dateOfBirth; }         set { _dateOfBirth = value; }     }      public string SocialSecurityNumber     {         get { return _socialSecurityNumber; }         set { _socialSecurityNumber = value; }     }      public PhoneInformation PhoneInformation { get; set; }      public InternationalSignup InternationalSignup { get; set; } 

How would I modify the above code to eliminate this error?