コード例 #1
0
 void Update()
 {
     if (value < 0)
     {
         this.textElement.color = this.colorIfNegative;
     }
     else
     {
         this.textElement.color = this.defaultColor;
     }
     if (this.isBool)
     {
         if (value < 0)
         {
             this.textElement.text = this.prefix + "False";
         }
         else
         {
             this.textElement.text = this.prefix + "True";
         }
     }
     else
     {
         this.textElement.text = prefix + MyRoutines.Round(value, this.decimalPlaces).ToString();
     }
 }
コード例 #2
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;
        }
    }
コード例 #3
0
 internal virtual void CheckRecorderValidity()
 {
     //implement validation checks
     //the output path should not be null
     this.isValid = true;
     if (string.IsNullOrEmpty(this.outputDetails.outputPath))
     {
         Debug.LogError("Output path not specified.");
         this.isValid = false;
     }
     if (this.outputDetails.isFile)
     {
         //if this is a file, the extension of the file in outputpath should match the file extension in outputdetails
         if (System.IO.Path.GetExtension(this.outputDetails.outputPath) != ("." + this.outputDetails.fileExtension))
         {
             Debug.LogError("File extension is invalid or no output file was specified.");
             this.isValid = false;
         }
     }
     //if we are storing data to a folder then create the target directory
     if (this.outputDetails.isFile == false)
     {
         if (MyRoutines.CreateDirectory(this.outputDetails.outputPath, false) == false)
         {
             Debug.LogError("The directory could not be created.");
             this.isValid = false;
         }
     }
 }
コード例 #4
0
    internal override void CaptureData()
    {
        this.dataList.Clear();
        //capture data is only called from inspector
        this.CheckRecorderValidity();
        if (this.isValid == false)
        {
            Debug.LogError("Curve recorder configuration is invalid. Could not extract curve data.");
            return;
        }
        AnimationCurve anim = null;

        switch (this.transferFunction)
        {
        case TransferFunctionType.Visual:
            anim = vehicle.visualProcessingFunction.curve;
            break;

        case TransferFunctionType.Motor:
            anim = vehicle.visuoMotorFunction.curve;
            break;

        case TransferFunctionType.Rotation:
            anim = vehicle.rotationFunction.curve;
            break;

        case TransferFunctionType.Drag:
            anim = vehicle.vehicleDragFunction.curve;
            break;
        }
        //convert the rate to an interval that can be used to increment the x value
        float interval = MyRoutines.ConvertRateToInterval(this.outputDetails.dataCaptureRate);

        if (anim == null)
        {
            Debug.LogError("Could not resolve curve.");
            return;
        }
        if (anim.length == 0)
        {
            Debug.LogError("The curve does not contain any keyframes.");
            return;
        }
        float maxX = MyRoutines.AnimationCurveMaximumXValue(anim);
        float x    = 0f;

        while (x < maxX)
        {
            this.dataList.Add(x, anim.Evaluate(x));
            x += interval;
        }
        //add in value for last x value
        this.dataList.Add(maxX, anim.Evaluate(maxX));
        //now save the data
        this.recording = true;
        this.SaveData();
        this.recording = false;
        Debug.Log("Saved data to " + this.outputDetails.outputPath);
    }
コード例 #5
0
    public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
    {
        SerializedProperty outputPath = prop.FindPropertyRelative("outputPath");
        int lines = 3;

        if (string.IsNullOrEmpty(outputPath.stringValue) == false)
        {
            lines += 2;
        }
        return(MyRoutines.GetGUIPropertyHeight(lines));
    }
コード例 #6
0
 private bool RecordEyeTestData()
 {
     //only record eye data if:
     //1. the eye test is enabled
     //2. there was no error while initializing the eyetest
     //3. the appropriate amount of time has lapsed since the last data serialization
     //4. the stop time has not been reached
     return((this.eyeTest.enabled == true) && (this.eyeTest.initializationError == false) &&
            (Time.time >= (MyRoutines.ConvertRateToInterval(this.eyeTest.rate) + this.lastEyeTestTime) &&
             (Time.time <= this.eyeTest.stopTime)));
 }
コード例 #7
0
    //private int activatedTriggerHash;


    // Use this for initialization
    void Start()
    {
        //get a reference to the animator component of the target light
        anim = GetComponent <Animator>();
        //this.activatedTriggerHash = Animator.StringToHash("VehicleActivated");

        if (vehicle == null)
        {
            //get a reference to the vehicle
            this.vehicle = MyRoutines.GetPrimaryVehicle();
        }
    }
コード例 #8
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        int lines = 0;

        if (EditorGUIUtility.wideMode == false)
        {
            lines = 5;
        }
        else
        {
            lines = 4;
        }
        return(MyRoutines.GetGUIPropertyHeight(lines));
    }
コード例 #9
0
    // Use this for initialization
    internal override void Start()
    {
        base.Start();
        this.isActivated = false;


        //disable the vehicle motor
        this.vehicle.disableMotor = true;
        //initialize the vehicle's eye memory
        eyeMemoryLeft  = new Queue <ColorInformation[, ]> (this.eyeMemoryCapacity);
        eyeMemoryRight = new Queue <ColorInformation[, ]> (this.eyeMemoryCapacity);
        //initialize the vehicle's eyes
        this.InitEye(this.leftEye);
        this.InitEye(this.rightEye);
        this.InvokeRepeating("ProcessScene", 0, MyRoutines.ConvertRateToInterval(this.lookRate));
    }
コード例 #10
0
    private static void GetLightSettings()
    {
        string output  = "";
        string newLine = System.Environment.NewLine;

        output += MyRoutines.GetObjectPropertyString("Ambient Light", RenderSettings.ambientLight);
        output += MyRoutines.GetObjectPropertyString("Ambient Intensity", RenderSettings.ambientIntensity);
        output += MyRoutines.GetObjectPropertyString("Ambient Mode", RenderSettings.ambientMode);
        output += MyRoutines.GetObjectPropertyString("Fog", RenderSettings.fog);
        output += MyRoutines.GetObjectPropertyString("Fog Color", RenderSettings.fogColor);
        output += MyRoutines.GetObjectPropertyString("Fog Mode", RenderSettings.fogMode);
        output += MyRoutines.GetObjectPropertyString("Fog Start", RenderSettings.fogStartDistance);
        output += MyRoutines.GetObjectPropertyString("Fog End", RenderSettings.fogEndDistance);
        output += MyRoutines.GetObjectPropertyString("Fog Skybox", RenderSettings.skybox);
        output += MyRoutines.GetObjectPropertyString("Sun ", RenderSettings.sun);
        Debug.Log(output);
    }
コード例 #11
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--;
        }
    }
コード例 #12
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;
    }
コード例 #13
0
 // Use this for initialization
 void Start()
 {
     if (useRate)
     {
         InvokeRepeating("DepositMarker", 0, MyRoutines.ConvertRateToInterval(rate));
     }
     else
     {
         //use a list of times
         //sort the times in increasing order
         List <float> t = new List <float>(this.times);
         t.Sort();
         foreach (float f in t)
         {
             Debug.Log(f.ToString());
         }
         q = new Queue <float> (t);
     }
 }
コード例 #14
0
    public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
    {
        SerializedProperty enabled      = prop.FindPropertyRelative("enabled");
        SerializedProperty outputFolder = prop.FindPropertyRelative("outputFolder");
        int lines = 0;

        if (enabled.boolValue == false)
        {
            lines = 1;
        }
        else
        {
            lines = 5;
        }
        if (string.IsNullOrEmpty(outputFolder.stringValue) == false && enabled.boolValue == true)
        {
            lines += 2;
        }
        return(MyRoutines.GetGUIPropertyHeight(lines));
    }
コード例 #15
0
 internal override void OnStart()
 {
     if (record)
     {
         //set data capture rate to zero to ensure that data capture is invoked from update
         int tempDataCaptureRate = this.outputDetails.dataCaptureRate;
         this.outputDetails.dataCaptureRate = 0;
         base.OnStart();
         if (this.isValid)
         {
             Time.captureFramerate = this.outputDetails.dataCaptureRate;
         }
         this.outputDetails.dataCaptureRate = tempDataCaptureRate;
         this.captureInterval = MyRoutines.ConvertRateToInterval(this.outputDetails.dataCaptureRate);
     }
     else
     {
         this.recording = false;
     }
 }
コード例 #16
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;
        }
    }
コード例 #17
0
 internal virtual void OnStart()
 {
     this.dataList.Clear();
     recording = false;
     this.CheckRecorderValidity();
     if (this.isValid == false)
     {
         return;
     }
     //if datacapture rate is greater than zero then call CaptureData routine with relevant interval
     if (this.outputDetails.dataCaptureRate > 0)
     {
         this.InvokeRepeating("CaptureData", 0, MyRoutines.ConvertRateToInterval(this.outputDetails.dataCaptureRate));
         this.runInUpdate = false;
     }
     else
     {
         runInUpdate = true;
     }
     //set recording to true
     recording = true;
 }
コード例 #18
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");
                }
            }
        }
    }
コード例 #19
0
 public static float GetGUIPropertyHeight(int lines)
 {
     return((MyRoutines.GetEditorGUIStandardLineHeight() * lines) + (MyRoutines.GetEditorGUIStandardVerticalSpacing() * (lines - 1)));
 }
コード例 #20
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(MyRoutines.GetGUIPropertyHeight(2));
 }
コード例 #21
0
 public static float GetEditorGUINextControlYPos(float yPos)
 {
     return(yPos + MyRoutines.GetEditorGUIStandardLineHeight() + MyRoutines.GetEditorGUIStandardVerticalSpacing());
 }