Hamilton asked her if another young person in the room was asleep and she confirmed it.
He told her to come to the doorway for a minute then leant down and whispered something inaudible in her ear.
She heard his next comment, "I can get in a lot of trouble for something I'm about to say".
Then he asked her if she had ever had sex and whether she watched porn. When the girl said she had not done either, he said goodnight and told her she was "a good girl".
She went back to bed but he stayed in the doorway for a short time and then left.
The girl immediately texted several people. Someone arrived at the house to collect her and a complaint was made to the police.
Questioned later, Hamilton told officers he went to the bedroom after hearing noises and on seeing the girl decided to confront her about concerns he had that she was using porn. He admitted making the statement about getting in trouble for what he was about to say.
At sentencing, Hamilton still disputed the girl's claim that he also asked her if she wanted to have sex.
Arguing the application for a discharge without conviction, counsel John Maroney pointed to a report from a Mason Clinic psychologist, which said Hamilton was slightly autistic and had a low risk of reoffending. The risk assessment was echoed by a probation report writer.
Hamilton's condition meant he was socially inept in certain situations and prone to saying one thing but meaning another, Maroney said.
Crown prosecutor Richard Annandale opposed the application, calling the offending "very sinister".
In the absence of a conviction Hamilton would continue his life as if in the eyes of the law his offending never happened, Annandale said. He said pre-sentence report writers had not identified any clear steps to mitigate against Hamilton similarly re-offending.
Taking into account Hamilton's personal mitigating factors, Judge McDonald reduced his assessment of the offending from serious to moderately so.
While there was no victim impact statement before the court, it could be inferred from the way the girl immediately fled the house that the effect of the offending on her was profound, the judge said.
Reasons advanced by Hamilton in his application to be discharged were not sufficient to meet the legal test - that the consequences of a conviction would be out of all proportion to the gravity of the offending, the judge said.
Hamilton had not shown the conviction would cause a barrier to any particular new employment role.
He said a conviction would cause loss of pride and mana but he lost that when he committed this crime, the judge said.
Given the non-custodial sentence imposed, a decision to add Hamilton to a national register of child sex offenders was at the court's discretion. Judge McDonald said it was unnecessary. He pointed to Hamilton's lack of previous relevant convictions and the time that had elapsed without further incident since the offending. There was nothing to suggest this was anything other than a one-off offence, the judge said.