コード例 #1
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        SerializedProperty color     = prop.FindPropertyRelative("color");
        SerializedProperty rotation  = prop.FindPropertyRelative("rotation");
        SerializedProperty intensity = prop.FindPropertyRelative("intensity");
        float lineHeight             = MyRoutines.GetEditorGUIStandardLineHeight();
        float yPos = pos.y;

        //color
        EditorGUI.PropertyField(new Rect(pos.x, yPos, pos.width, lineHeight), color, new GUIContent(color.displayName, color.tooltip));
        //intensity
        yPos = MyRoutines.GetEditorGUINextControlYPos(yPos);
        EditorGUI.PropertyField(new Rect(pos.x, yPos, pos.width, lineHeight), intensity, new GUIContent(intensity.displayName, intensity.tooltip));
        //rotation
        yPos = MyRoutines.GetEditorGUINextControlYPos(yPos);
        EditorGUI.PropertyField(new Rect(pos.x, yPos, pos.width, lineHeight), rotation, new GUIContent(rotation.displayName, rotation.tooltip));
        yPos = MyRoutines.GetEditorGUINextControlYPos(yPos);
        if (EditorGUIUtility.wideMode == false)
        {
            yPos = MyRoutines.GetEditorGUINextControlYPos(yPos);
        }
        GUIContent buttonGUIContent = new GUIContent("Same As Existing Directional Light", "Copies the settings of the scenes's main directional light.");

        if (GUI.Button(new Rect(pos.x, yPos, pos.width, lineHeight), buttonGUIContent))
        {
            Light light = GameObject.FindGameObjectWithTag(TagManager.DirectionalLight).GetComponent <Light> ();
            color.colorValue      = light.color;
            rotation.vector3Value = light.transform.localEulerAngles;
            //rotation.vector3Value = light.transform.rotation.eulerAngles;
            intensity.floatValue = light.intensity;
        }
    }
コード例 #2
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        SerializedProperty enabled               = prop.FindPropertyRelative("enabled");
        SerializedProperty outputFolder          = prop.FindPropertyRelative("outputFolder");
        SerializedProperty rate                  = prop.FindPropertyRelative("rate");
        SerializedProperty captureProcessedImage = prop.FindPropertyRelative("captureProcessedImage");
        SerializedProperty stopTime              = prop.FindPropertyRelative("stopTime");
        float lineHeight = MyRoutines.GetEditorGUIStandardLineHeight();

        EditorGUI.PropertyField(new Rect(pos.x, pos.y, pos.width, lineHeight), enabled, new GUIContent("Eye Test", enabled.tooltip));

        if (enabled.boolValue)
        {
            EditorGUI.indentLevel++;
            string tooltip = MyRoutines.GetTooltip(typeof(EyeTest), "outputFolder");

            float ypos = MyRoutines.GetEditorGUINextControlYPos(pos.y);
            EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), captureProcessedImage);
            ypos = MyRoutines.GetEditorGUINextControlYPos(ypos);
            Rect controlRect = new Rect(pos.x, ypos, pos.width, lineHeight);              //lineheight
            //MyRoutines.CreateScreenRecordingControl (outputFolder.displayName, tooltip, controlRect, outputFolder, rate, "EyeTestData");
            MyRoutines.CreateOutputPathControl(outputFolder.displayName, tooltip, controlRect, outputFolder, false, string.Empty, string.Empty);

            if (string.IsNullOrEmpty(outputFolder.stringValue) == false)
            {
                ypos        = MyRoutines.GetEditorGUINextControlYPos(ypos);
                controlRect = new Rect(pos.x, ypos, pos.width, lineHeight * 2);
                EditorGUI.HelpBox(controlRect, "The contents of the selected folder will be overwritten.", MessageType.Warning);
                ypos = MyRoutines.GetEditorGUINextControlYPos(ypos) + lineHeight;
            }
            else
            {
                ypos = MyRoutines.GetEditorGUINextControlYPos(ypos);
            }

            EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), rate);
            ypos = MyRoutines.GetEditorGUINextControlYPos(ypos);
            EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), stopTime);
            if (stopTime.floatValue <= 0)
            {
                stopTime.floatValue = Mathf.Infinity;
            }
            EditorGUI.indentLevel--;
        }
    }
コード例 #3
0
//	public static void CreateScreenRecordingControl(string displayName, string tooltip, Rect pos, SerializedProperty outputFolder, SerializedProperty rate, string defaultFolderName)
//	{
//
//		float labelWidth = MyRoutines.GetEditorGUILabelWidth();
//		float padding = MyRoutines.GetEditorGUIControlSpacing();
//		float lineHeight = MyRoutines.GetEditorGUIStandardLineHeight ();
//		int folderButtonWidth = 25;
//
//		//create the label field
//		EditorGUI.LabelField (new Rect (pos.x, pos.y, labelWidth, lineHeight), new GUIContent (displayName, tooltip));
//		//reset the indent level
//		int indentLevel = EditorGUI.indentLevel;
//		EditorGUI.indentLevel = 0;
//		//disable the GUI
//		GUI.enabled = false;
//		if (string.IsNullOrEmpty(outputFolder.stringValue))
//			outputFolder.stringValue = System.IO.Path.Combine(Application.dataPath, defaultFolderName);
//		float outputFolderWidth = pos.width - labelWidth - folderButtonWidth - padding;
//		//create the outputfolder field
//		EditorGUI.TextField (new Rect (pos.x + labelWidth, pos.y, outputFolderWidth, lineHeight), outputFolder.stringValue);
//		//renable the GUI
//		GUI.enabled = true;
//		float buttonXPos = pos.x + labelWidth + outputFolderWidth + padding;
//		if (GUI.Button(new Rect(buttonXPos, pos.y, folderButtonWidth, lineHeight), "...")) {
//			string value = EditorUtility.OpenFolderPanel ("Select Output Folder", "", "");
//			if (string.IsNullOrEmpty (value) == false)
//				outputFolder.stringValue = value;
//		}
//		EditorGUI.indentLevel = indentLevel;
//		//get the vertical position of the next control
//		float ypos = MyRoutines.GetEditorGUINextControlYPos(pos.y);
//		EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), rate);
//	}

    public static void CreateOutputPathControl(string displayName, string tooltip, Rect pos, SerializedProperty outputPath, bool isFile, string fileExtension, string defaultFileName)
    {
        float labelWidth        = MyRoutines.GetEditorGUILabelWidth();
        float padding           = MyRoutines.GetEditorGUIControlSpacing();
        float lineHeight        = MyRoutines.GetEditorGUIStandardLineHeight();
        int   folderButtonWidth = 25;

        //create the label field
        EditorGUI.LabelField(new Rect(pos.x, pos.y, labelWidth, lineHeight), new GUIContent(displayName, tooltip));
        //reset the indent level
        int indentLevel = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;
        //disable the GUI
        GUI.enabled = false;
//		if (string.IsNullOrEmpty(outputPath.stringValue))
//			outputPath.stringValue = Application.dataPath;
        float outputFolderWidth = pos.width - labelWidth - folderButtonWidth - padding;

        //create the outputfolder field
        EditorGUI.TextField(new Rect(pos.x + labelWidth, pos.y, outputFolderWidth, lineHeight), outputPath.stringValue);
        //renable the GUI
        GUI.enabled = true;
        float buttonXPos = pos.x + labelWidth + outputFolderWidth + padding;

        if (GUI.Button(new Rect(buttonXPos, pos.y, folderButtonWidth, lineHeight), "..."))
        {
            string value = string.Empty;
            if (isFile == false)
            {
                //folder
                value = EditorUtility.OpenFolderPanel("Select Output Folder", outputPath.stringValue, "");
            }
            else
            {
                //file
                value = EditorUtility.SaveFilePanel("Save File", outputPath.stringValue, defaultFileName + "." + fileExtension, fileExtension);
            }
            if (string.IsNullOrEmpty(value) == false)
            {
                outputPath.stringValue = value;
            }
        }
        EditorGUI.indentLevel = indentLevel;
    }
コード例 #4
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        SerializedProperty outputPath      = prop.FindPropertyRelative("outputPath");
        SerializedProperty dataCaptureRate = prop.FindPropertyRelative("dataCaptureRate");
        SerializedProperty stopTime        = prop.FindPropertyRelative("stopTime");
        float             lineHeight       = MyRoutines.GetEditorGUIStandardLineHeight();
        DataOutputDetails outputDetails    = fieldInfo.GetValue(prop.serializedObject.targetObject) as DataOutputDetails;
        bool   isFile          = outputDetails.isFile;
        string fileExtension   = outputDetails.fileExtension;
        string defaultFileName = outputDetails.defaultFileName;
        string tooltip         = MyRoutines.GetTooltip(typeof(DataOutputDetails), "outputPath");

        //create the output path control
        MyRoutines.CreateOutputPathControl(outputPath.displayName, tooltip, pos, outputPath, isFile, fileExtension, defaultFileName);
        float ypos;

        if (string.IsNullOrEmpty(outputPath.stringValue) == false)
        {
            ypos = MyRoutines.GetEditorGUINextControlYPos(pos.y);
            Rect controlRect = new Rect(pos.x, ypos, pos.width, lineHeight * 2);
            EditorGUI.HelpBox(controlRect, "The contents of the selected folder will be overwritten.", MessageType.Warning);
            ypos = MyRoutines.GetEditorGUINextControlYPos(ypos) + lineHeight;
        }
        else
        {
            ypos = MyRoutines.GetEditorGUINextControlYPos(pos.y);
        }
        //create the datacapture rate field
        tooltip = MyRoutines.GetTooltip(typeof(DataOutputDetails), "dataCaptureRate");
        string rateDisplayName = outputDetails.rateFieldLabel;

        EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), dataCaptureRate, new GUIContent(rateDisplayName, tooltip));
        //create the stopTime field
        ypos = MyRoutines.GetEditorGUINextControlYPos(ypos);
        EditorGUI.PropertyField(new Rect(pos.x, ypos, pos.width, lineHeight), stopTime);
        if (stopTime.floatValue <= 0)
        {
            stopTime.floatValue = Mathf.Infinity;
        }
    }
コード例 #5
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        SerializedProperty showScale  = prop.FindPropertyRelative("showScale");
        SerializedProperty curveColor = prop.FindPropertyRelative("curveColor");
        SerializedProperty yScale     = prop.FindPropertyRelative("yScale");
        SerializedProperty xScale     = prop.FindPropertyRelative("xScale");
        SerializedProperty yMaxScale  = prop.FindPropertyRelative("yMaxScale");
        SerializedProperty xMaxScale  = prop.FindPropertyRelative("xMaxScale");
        SerializedProperty curve      = prop.FindPropertyRelative("curve");
        SerializedProperty curveType  = prop.FindPropertyRelative("curveType");

        float padding    = MyRoutines.GetEditorGUIControlSpacing();
        float lineHeight = MyRoutines.GetEditorGUIStandardLineHeight();
        float yPos       = pos.y;
        float curveWidth = pos.width;



        string     tooltip  = MyRoutines.GetTooltip(prop.serializedObject.targetObject.GetType(), prop.name);
        GUIContent gContent = new GUIContent(label.text, tooltip);          //prop.tooltip doesn't work

        //draw the slider if required
        if (showScale.boolValue)
        {
            curveWidth = 75;
            EditorGUI.IntSlider(new Rect(pos.x, yPos, pos.width - curveWidth, lineHeight), yScale, 0, yMaxScale.intValue, gContent);
        }

        //draw curve
        if (showScale.boolValue)
        {
            int indent = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            EditorGUI.CurveField(new Rect(pos.x + (pos.width - curveWidth) + padding, yPos, curveWidth - padding, lineHeight), curve, curveColor.colorValue, new Rect(0, 0, xScale.intValue, yScale.intValue), GUIContent.none);
            EditorGUI.indentLevel = indent;
        }
        else
        {
            EditorGUI.CurveField(new Rect(pos.x, yPos, curveWidth - padding, lineHeight), curve, curveColor.colorValue, new Rect(0, 0, xMaxScale.intValue, yScale.intValue), gContent);
        }


        //buttons
        yPos = MyRoutines.GetEditorGUINextControlYPos(yPos);

        float      buttonWidth      = (pos.width / 3) - padding;
        GUIContent buttonGUIContent = new GUIContent("Reset", "Reset the curve to its default setting.");

        if (GUI.Button(new Rect(pos.x, yPos, buttonWidth, lineHeight), buttonGUIContent))
        {
            //reset the animation curve
            //get a reference to the curve
            ScaledCurve c = (ScaledCurve)fieldInfo.GetValue(prop.serializedObject.targetObject);
            //reset the curve
            curve.animationCurveValue = c.ResetCurve();
        }
        buttonGUIContent = new GUIContent("Save", "Saves curve data to an asset file.");
        if (GUI.Button(new Rect(pos.x + buttonWidth + padding, yPos, buttonWidth, lineHeight), buttonGUIContent))
        {
            string path = EditorUtility.SaveFilePanelInProject("Save Curve", "CurveData", "asset", "Please enter a file name to save the curve data to.");
            if (string.IsNullOrEmpty(path) == false)
            {
                //save curve data as scriptable object instance
                SerializedCurve asset = ScriptableObject.CreateInstance <SerializedCurve> ();
                asset.curve     = new SerializableCurve(curve.animationCurveValue);
                asset.curveType = curveType.stringValue;
                AssetDatabase.CreateAsset(asset, path);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
        buttonGUIContent = new GUIContent("Load", "Loads curve data from an asset file.");
        if (GUI.Button(new Rect(pos.x + ((buttonWidth + padding) * 2), yPos, buttonWidth, lineHeight), buttonGUIContent))
        {
            string path = EditorUtility.OpenFilePanel("Load Curve", Application.dataPath, "asset");
            if (string.IsNullOrEmpty(path) == false)
            {
                //load curve data from scriptable object
                path = path.Replace(Application.dataPath, "Assets");
                SerializedCurve asset = AssetDatabase.LoadAssetAtPath <SerializedCurve>(path);
                if (asset.curveType == curveType.stringValue)
                {
                    //correct type - replace curve with serialized curve data
                    curve.animationCurveValue = asset.curve.ToAnimationCurve();
                }
                else
                {
                    EditorUtility.DisplayDialog("Error", "Saved curve data is of the wrong type.", "OK");
                }
            }
        }
    }
コード例 #6
0
 public static float GetGUIPropertyHeight(int lines)
 {
     return((MyRoutines.GetEditorGUIStandardLineHeight() * lines) + (MyRoutines.GetEditorGUIStandardVerticalSpacing() * (lines - 1)));
 }
コード例 #7
0
 public static float GetEditorGUINextControlYPos(float yPos)
 {
     return(yPos + MyRoutines.GetEditorGUIStandardLineHeight() + MyRoutines.GetEditorGUIStandardVerticalSpacing());
 }