Ejemplo n.º 1
0
        IEnumerator Coroutine_LoadProjectorInternalParameters(Transform panel, Dictionary <string, Selectable> elements)
        {
            var    filters      = new string[] { ".dat" };
            string startingPath = default;

#if UNITY_EDITOR
            startingPath = Application.dataPath + "/Resources/";
#else
            startingPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
#endif
            yield return(DanbiFileSys.OpenLoadDialog(startingPath, filters, "Load Camera Externel Paramaters (Scriptable Object)", "Select"));

            DanbiFileSys.GetResourcePathIntact(out m_loadPath, out _);

            // Load the Internal parameters.
            if (!File.Exists(m_loadPath))
            {
                yield break;
            }

            var bf = new BinaryFormatter();
            DanbiCameraInternalData loaded = null;
            using (var file = File.Open(m_loadPath, FileMode.Open))
            {
                loaded = bf.Deserialize(file) as DanbiCameraInternalData;
            }

            yield return(new WaitUntil(() => !(loaded is null)));

            m_internalData = loaded;

            m_selectedPanoramaInternalParameterText.text = m_loadPath;

            (elements["radialCoefficientX"] as TMP_InputField).text = m_internalData.radialCoefficient.x.ToString();
            onRadialCoefficientXUpdate?.Invoke(m_internalData.radialCoefficient.x);

            (elements["radialCoefficientY"] as TMP_InputField).text = m_internalData.radialCoefficient.y.ToString();
            onRadialCoefficientYUpdate?.Invoke(m_internalData.radialCoefficient.y);

            (elements["radialCoefficientZ"] as TMP_InputField).text = m_internalData.radialCoefficient.z.ToString();
            onRadialCoefficientZUpdate?.Invoke(m_internalData.radialCoefficient.z);

            (elements["tangentialCoefficientX"] as TMP_InputField).text = m_internalData.tangentialCoefficient.x.ToString();
            onTangentialCoefficientXUpdate?.Invoke(m_internalData.tangentialCoefficient.x);

            (elements["tangentialCoefficientY"] as TMP_InputField).text = m_internalData.tangentialCoefficient.y.ToString();
            onTangentialCoefficientYUpdate?.Invoke(m_internalData.tangentialCoefficient.y);

            (elements["principalPointX"] as TMP_InputField).text = m_internalData.principalPoint.x.ToString();
            onPrincipalPointXUpdate?.Invoke(m_internalData.principalPoint.x);

            (elements["principalPointY"] as TMP_InputField).text = m_internalData.principalPoint.y.ToString();
            onPrincipalPointYUpdate?.Invoke(m_internalData.principalPoint.y);

            (elements["focalLengthX"] as TMP_InputField).text = m_internalData.focalLength.x.ToString();
            onFocalLengthXUpdate?.Invoke(m_internalData.focalLength.x);

            (elements["focalLengthY"] as TMP_InputField).text = m_internalData.focalLength.y.ToString();
            onFocalLengthYUpdate?.Invoke(m_internalData.focalLength.y);
        }
Ejemplo n.º 2
0
        protected override void LoadPreviousValues(params Selectable[] uiElements)
        {
            string prevLoadPath = PlayerPrefs.GetString(playerPrefsKeyRoot + "loadPath", default);

            if (string.IsNullOrEmpty(prevLoadPath))
            {
                return;
            }

            // Load the previous Internal parameters.
            if (!File.Exists(prevLoadPath))
            {
                return;
            }

            var bf   = new BinaryFormatter();
            var file = File.Open(prevLoadPath, FileMode.Open);

            m_internalData = bf.Deserialize(file) as DanbiCameraInternalData;

            if (m_internalData is null)
            {
                return;
            }

            (uiElements[1] as TMP_InputField).text = m_internalData.radialCoefficient.x.ToString();
            onRadialCoefficientXUpdate?.Invoke(m_internalData.radialCoefficient.x);

            (uiElements[2] as TMP_InputField).text = m_internalData.radialCoefficient.y.ToString();
            onRadialCoefficientYUpdate?.Invoke(m_internalData.radialCoefficient.y);

            (uiElements[3] as TMP_InputField).text = m_internalData.radialCoefficient.z.ToString();
            onRadialCoefficientZUpdate?.Invoke(m_internalData.radialCoefficient.z);

            (uiElements[4] as TMP_InputField).text = m_internalData.tangentialCoefficient.x.ToString();
            onTangentialCoefficientXUpdate?.Invoke(m_internalData.tangentialCoefficient.x);

            (uiElements[5] as TMP_InputField).text = m_internalData.tangentialCoefficient.y.ToString();
            onTangentialCoefficientYUpdate?.Invoke(m_internalData.tangentialCoefficient.y);

            (uiElements[6] as TMP_InputField).text = m_internalData.principalPoint.x.ToString();
            onPrincipalPointXUpdate?.Invoke(m_internalData.principalPoint.x);

            (uiElements[7] as TMP_InputField).text = m_internalData.principalPoint.y.ToString();
            onPrincipalPointYUpdate?.Invoke(m_internalData.principalPoint.y);

            (uiElements[8] as TMP_InputField).text = m_internalData.focalLength.x.ToString();
            onFocalLengthXUpdate?.Invoke(m_internalData.focalLength.x);

            (uiElements[9] as TMP_InputField).text = m_internalData.focalLength.y.ToString();
            onFocalLengthYUpdate?.Invoke(m_internalData.focalLength.y);
        }