i got it to work… with OnGUI() , suppose its just as easy to use with new UI
someone posted here about it
this is my codes im using for simple calculator… its meant to help me with 3d modelling, the purpose is to have one value be always present, and paste in the other value… so that one of the values dont have to be entered Every time, its always there…
suppose it could be better?? … i did it quickly, and experimentally/hacky , just trying stuff lol
Calculator code etc… see bottom of it for copy/paste
```csharp
*using UnityEngine;
using System.Collections;
public class Calculator : MonoBehaviour
{
public float valueA = 0.0f;
public float valueB = 0.0f;
public float resultant = 0.0f;
public string testValue;
void Start()
{
Screen.SetResolution (256, 140, false); //make the program a little window dealy
}
void OnGUI()
{
string resultantString = resultant.ToString();
GUI.SetNextControlName("valueAField");
valueA = float.Parse (GUI.TextField(new Rect(10, 10, 100, 20), valueA.ToString ("0.00000"))); //number top
GUI.SetNextControlName("valueBField");
valueB = float.Parse (GUI.TextField(new Rect(10, 30, 100, 20), valueB.ToString ("0.00000"))); //number bot
GUI.Label(new Rect(15, 50, 200, 20), resultantString ); //result number
GUI.Label(new Rect(130, 10, 250, 20), "- dividend / minuend"); //labels
GUI.Label(new Rect(130, 30, 250, 20), "- divisor / subtrahend");
GUI.Label(new Rect(130, 50, 280, 20), "- Result");
if (GUI.Button(new Rect(10, 75, 30, 30), " + ")) //mathamagicks
{
resultant = valueA + valueB;
}
if (GUI.Button(new Rect(50, 75, 30, 30), " - "))
{
resultant = valueA - valueB;
}
if (GUI.Button(new Rect(90, 75, 30, 30), "x "))
{
resultant = valueA * valueB;
}
if (GUI.Button(new Rect(130, 75, 30, 30), " / "))
{
resultant = valueA / valueB;
}
//copy to windows clipboard
if (GUI.Button(new Rect(170, 110, 80, 30), "CopyResult"))
{
GUI.FocusControl("resultantField");
TextEditor te2 = new TextEditor { content = new GUIContent(resultantString) };
te2.SelectAll();
te2.Copy();
}
//paste to here from windows clipboard[
if (GUI.Button(new Rect(10, 110, 70, 30), "Paste Top"))
{
string topStringACB = ClipboardHelper.clipBoard;
valueA = float.Parse (topStringACB);
}
if (GUI.Button(new Rect(85, 110, 70, 30), "Paste Bot"))
{
string botStringBCB = ClipboardHelper.clipBoard;
valueB = float.Parse (botStringBCB);
}
}
}*
```
code from the site linked
```csharp
*// C#
// ClipboardHelper.cs
using UnityEngine;
using System;
using System.Reflection;
[System.Serializable]
public class ClipboardHelper
{
private static PropertyInfo m_systemCopyBufferProperty = null;
private static PropertyInfo GetSystemCopyBufferProperty()
{
if (m_systemCopyBufferProperty == null)
{
Type T = typeof(GUIUtility);
m_systemCopyBufferProperty = T.GetProperty(“systemCopyBuffer”, BindingFlags.Static | BindingFlags.NonPublic);
if (m_systemCopyBufferProperty == null)
throw new Exception(“Can’t access internal member ‘GUIUtility.systemCopyBuffer’ it may have been removed / renamed”);
}
return m_systemCopyBufferProperty;
}
public static string clipBoard
{
get
{
PropertyInfo P = GetSystemCopyBufferProperty();
return (string)P.GetValue(null,null);
}
set
{
PropertyInfo P = GetSystemCopyBufferProperty();
P.SetValue(null,value,null);
}
}
}*
```