|
|
|
|
|
|
Scale |
|
|
|
} |
|
|
|
|
|
|
|
// make custom control of cursor position in TextField.
|
|
|
|
// The decimal point input-and-parse exists problem.
|
|
|
|
Widget getCardRow(ETransfrom type, bool hasRef) { |
|
|
|
var xValue = hasRef |
|
|
|
? type == ETransfrom.Position |
|
|
|
|
|
|
: this.transformRef.localScale.x.ToString() |
|
|
|
: ""; |
|
|
|
|
|
|
|
// Using individual TextEditingController to control TextField cursor position.
|
|
|
|
var xValueController = TextEditingController.fromValue( |
|
|
|
new TextEditingValue(xValue, TextSelection.collapsed(this.oldCursorPosition)) |
|
|
|
); |
|
|
|
|
|
|
? this.transformRef.position.y.ToString() |
|
|
|
: type == ETransfrom.Scale |
|
|
|
: type == ETransfrom.Rotation |
|
|
|
? this.transformRef.localEulerAngles.y.ToString() |
|
|
|
: this.transformRef.localScale.y.ToString() |
|
|
|
: ""; |
|
|
|
|
|
|
controller: xValueController, |
|
|
|
onChanged: hasRef |
|
|
|
? (str) => { |
|
|
|
// While the TextField value changed, try to parse and assign to transformRef.
|
|
|
|
this.oldCursorPosition = xValueController.selection.startPos.offset; |
|
|
|
if (str == "" || str[0] == '0') { |
|
|
|
this.oldCursorPosition = 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.oldCursorPosition = |
|
|
|
xValueController.selection.startPos.offset; |
|
|
|
} |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case ETransfrom.Position: |
|
|
|
|
|
|
this.setState(() => { |
|
|
|
float result = 0; |
|
|
|
float.TryParse(str, out result); |
|
|
|
this.oldCursorPosition = yValueController.selection.startPos.offset; |
|
|
|
if (str == "" || str[0] == '0') { |
|
|
|
this.oldCursorPosition = 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.oldCursorPosition = |
|
|
|
yValueController.selection.startPos.offset; |
|
|
|
} |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case ETransfrom.Position: |
|
|
|
|
|
|
this.setState(() => { |
|
|
|
float result = 0; |
|
|
|
float.TryParse(str, out result); |
|
|
|
this.oldCursorPosition = zValueController.selection.startPos.offset; |
|
|
|
Debug.Log(result); |
|
|
|
if (str == "" || str[0] == '0') { |
|
|
|
this.oldCursorPosition = 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.oldCursorPosition = |
|
|
|
zValueController.selection.startPos.offset; |
|
|
|
} |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case ETransfrom.Position: |
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: new List<Widget> { |
|
|
|
new UnityObjectDetector( |
|
|
|
// When receiving a GameObject, get its transfrom.
|
|
|
|
this.objectRef = details.objectReferences[0] as GameObject; |
|
|
|
if (this.objectRef) { |
|
|
|
this.transformRef = this.objectRef.transform; |
|
|
|
var gameObj = details.objectReferences[0] as GameObject; |
|
|
|
if (gameObj) { |
|
|
|
this.objectRef = gameObj; |
|
|
|
if (this.objectRef) { |
|
|
|
this.transformRef = this.objectRef.transform; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|