Exemple #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            FairyGUI.UIPanel panel = target as FairyGUI.UIPanel;
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
            DrawPropertiesExcluding(serializedObject, propertyToExclude);
#endif
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Package Name");
            if (GUILayout.Button(packageName.stringValue, "ObjectField"))
            {
                EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
            }

            if (GUILayout.Button("Clear", GUILayout.Width(50)))
            {
                bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
                panel.SendMessage("OnUpdateSource", new object[] { null, null, null, !isPrefab });

#if UNITY_5_3_OR_NEWER
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#elif UNITY_5
                EditorApplication.MarkSceneDirty();
#else
                EditorUtility.SetDirty(panel);
#endif
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Component Name");
            if (GUILayout.Button(componentName.stringValue, "ObjectField"))
            {
                EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(renderMode);
            if ((RenderMode)renderMode.enumValueIndex != RenderMode.ScreenSpaceOverlay)
            {
                EditorGUILayout.PropertyField(renderCamera);
            }
            int oldSortingOrder = panel.sortingOrder;
            EditorGUILayout.PropertyField(sortingOrder);
            EditorGUILayout.PropertyField(fairyBatching);
            EditorGUILayout.PropertyField(hitTestMode);
            EditorGUILayout.PropertyField(touchDisabled);
            EditorGUILayout.PropertyField(setNativeChildrenOrder);
            EditorGUILayout.LabelField("UI Transform", (GUIStyle)"OL Title");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(position);
            EditorGUILayout.PropertyField(rotation);
            EditorGUILayout.PropertyField(scale);
            EditorGUILayout.Space();

            FairyGUI.FitScreen oldFitScreen = (FairyGUI.FitScreen)fitScreen.enumValueIndex;
            EditorGUILayout.PropertyField(fitScreen);

            if (serializedObject.ApplyModifiedProperties())
            {
                if (PrefabUtility.GetPrefabType(panel) != PrefabType.Prefab)
                {
                    panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FairyGUI.FitScreen)fitScreen.enumValueIndex != oldFitScreen);
                }
            }
        }
    private void Gradient(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);

            EditorGUILayout.BeginVertical(style);
            {
                DrawProperty(143, true);
                MaterialProperty gradIsRadial = matProperties[143];
                if (gradIsRadial.floatValue == 1)
                {
                    targetMat.EnableKeyword("RADIALGRADIENT_ON");
                    DrawProperty(31);
                    DrawProperty(32);
                    DrawProperty(34);
                    DrawProperty(141);
                }
                else
                {
                    targetMat.DisableKeyword("RADIALGRADIENT_ON");
                    bool simpleGradient   = oldKeyWords.Contains("GRADIENT2COL_ON");
                    bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
                    if (simpleGradient && !simpleGradToggle)
                    {
                        targetMat.DisableKeyword("GRADIENT2COL_ON");
                    }
                    else if (!simpleGradient && simpleGradToggle)
                    {
                        targetMat.EnableKeyword("GRADIENT2COL_ON");
                    }
                    DrawProperty(31);
                    DrawProperty(32);
                    if (!simpleGradToggle)
                    {
                        DrawProperty(33);
                    }
                    DrawProperty(34);
                    if (!simpleGradToggle)
                    {
                        DrawProperty(35);
                    }
                    if (!simpleGradToggle)
                    {
                        DrawProperty(141);
                    }
                    DrawProperty(142);
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Overlay(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);
            EditorGUILayout.BeginVertical(style);
            {
                bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
                bool isMultMode = multModeOn;
                isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
                if (multModeOn != isMultMode)
                {
                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    }
                    if (isMultMode)
                    {
                        multModeOn = true;
                        targetMat.EnableKeyword("OVERLAYMULT_ON");
                    }
                    else
                    {
                        targetMat.DisableKeyword("OVERLAYMULT_ON");
                    }
                }
                if (multModeOn)
                {
                    GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
                }
                else
                {
                    GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
                }

                for (int i = 165; i <= 168; i++)
                {
                    DrawProperty(i);
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void ColorRamp(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("COLORRAMP_ON");
            EditorGUILayout.BeginVertical(style);
            {
                bool useEditableGradient = false;
                if (AssetDatabase.Contains(targetMat))
                {
                    useEditableGradient = oldKeyWords.Contains("GRADIENTCOLORRAMP_ON");
                    bool gradientTex = useEditableGradient;
                    gradientTex = GUILayout.Toggle(gradientTex, new GUIContent("Use Editable Gradient?"));
                    if (useEditableGradient != gradientTex)
                    {
                        if (!Application.isPlaying)
                        {
                            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        }
                        if (gradientTex)
                        {
                            useEditableGradient = true;
                            targetMat.EnableKeyword("GRADIENTCOLORRAMP_ON");
                        }
                        else
                        {
                            targetMat.DisableKeyword("GRADIENTCOLORRAMP_ON");
                        }
                    }
                    if (useEditableGradient)
                    {
                        matEditor.ShaderProperty(matProperties[164], matProperties[164].displayName);
                    }
                }
                else
                {
                    GUILayout.Label("*Save to folder to allow for dynamic Gradient property", smallLabelStyle);
                }
                if (!useEditableGradient)
                {
                    GUILayout.Label("Texture does not support Tiling", smallLabelStyle);
                    DrawProperty(51);
                }

                DrawProperty(52);
                DrawProperty(53, true);
                MaterialProperty colorRampOut = matProperties[53];
                if (colorRampOut.floatValue == 1)
                {
                    targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
                }
                else
                {
                    targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
                }
                DrawProperty(155);
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("COLORRAMP_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void ColorChange(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("CHANGECOLOR_ON");
            EditorGUILayout.BeginVertical(style);
            {
                for (int i = 123; i < 127; i++)
                {
                    DrawProperty(i);
                }

                EditorGUILayout.Separator();
                ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
                bool toggle2 = ini;
                toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
                if (ini != toggle2 && !Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
                if (toggle2)
                {
                    targetMat.EnableKeyword("CHANGECOLOR2_ON");
                    for (int i = 146; i < 149; i++)
                    {
                        DrawProperty(i);
                    }
                }
                else
                {
                    targetMat.DisableKeyword("CHANGECOLOR2_ON");
                }

                EditorGUILayout.Separator();
                ini     = oldKeyWords.Contains("CHANGECOLOR3_ON");
                toggle2 = ini;
                toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
                if (ini != toggle2 && !Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
                if (toggle2)
                {
                    targetMat.EnableKeyword("CHANGECOLOR3_ON");
                    for (int i = 149; i < 152; i++)
                    {
                        DrawProperty(i);
                    }
                }
                else
                {
                    targetMat.DisableKeyword("CHANGECOLOR3_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("CHANGECOLOR_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Blending(string inspector, string keyword)
    {
        bool             toggle = oldKeyWords.Contains(keyword);
        MaterialProperty srcM   = ShaderGUI.FindProperty("_MySrcMode", matProperties);
        MaterialProperty dstM   = ShaderGUI.FindProperty("_MyDstMode", matProperties);

        if (srcM.floatValue == 0 && dstM.floatValue == 0)
        {
            srcM.floatValue = 5;
            dstM.floatValue = 10;
        }
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Look for 'ShaderLab: Blending' if you don't know what this is", smallLabelStyle);
                if (GUILayout.Button("Back To Default Blending"))
                {
                    srcM.floatValue = 5;
                    dstM.floatValue = 10;
                    targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
                }
                srcMode         = (BlendMode)srcM.floatValue;
                dstMode         = (BlendMode)dstM.floatValue;
                srcMode         = (BlendMode)EditorGUILayout.EnumPopup("SrcMode", srcMode);
                dstMode         = (BlendMode)EditorGUILayout.EnumPopup("DstMode", dstMode);
                srcM.floatValue = (float)(srcMode);
                dstM.floatValue = (float)(dstMode);

                ini    = oldKeyWords.Contains("PREMULTIPLYALPHA_ON");
                toggle = EditorGUILayout.Toggle("Premultiply Alpha?", ini);
                if (ini != toggle && !Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
                if (toggle)
                {
                    targetMat.EnableKeyword("PREMULTIPLYALPHA_ON");
                }
                else
                {
                    targetMat.DisableKeyword("PREMULTIPLYALPHA_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            srcM.floatValue = 5;
            dstM.floatValue = 10;
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Outline(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + ".Outline";
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("OUTBASE_ON");
            EditorGUILayout.BeginVertical(style);
            {
                DrawProperty(14);
                DrawProperty(15);
                DrawProperty(16);
                DrawProperty(17, true);
                MaterialProperty outline8dir = matProperties[17];
                if (outline8dir.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASE8DIR_ON");
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASE8DIR_ON");
                }

                DrawLine(Color.grey, 1, 3);
                DrawProperty(19, true);
                MaterialProperty outlinePixel = matProperties[19];
                if (outlinePixel.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASEPIXELPERF_ON");
                    DrawProperty(20);
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASEPIXELPERF_ON");
                    DrawProperty(18);
                }

                DrawLine(Color.grey, 1, 3);
                DrawProperty(21, true);
                MaterialProperty outlineTex = matProperties[21];
                if (outlineTex.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTTEX_ON");
                    DrawProperty(22);
                    DrawProperty(23);
                    DrawProperty(24);
                    DrawProperty(25, true);
                    MaterialProperty outlineTexGrey = matProperties[25];
                    if (outlineTexGrey.floatValue == 1)
                    {
                        targetMat.EnableKeyword("OUTGREYTEXTURE_ON");
                    }
                    else
                    {
                        targetMat.DisableKeyword("OUTGREYTEXTURE_ON");
                    }
                }
                else
                {
                    targetMat.DisableKeyword("OUTTEX_ON");
                }

                DrawLine(Color.grey, 1, 3);
                DrawProperty(26, true);
                MaterialProperty outlineDistort = matProperties[26];
                if (outlineDistort.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTDIST_ON");
                    DrawProperty(27);
                    DrawProperty(28);
                    DrawProperty(29);
                    DrawProperty(30);
                }
                else
                {
                    targetMat.DisableKeyword("OUTDIST_ON");
                }

                DrawLine(Color.grey, 1, 3);
                DrawProperty(71, true);
                MaterialProperty onlyOutline = matProperties[71];
                if (onlyOutline.floatValue == 1)
                {
                    targetMat.EnableKeyword("ONLYOUTLINE_ON");
                }
                else
                {
                    targetMat.DisableKeyword("ONLYOUTLINE_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("OUTBASE_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
Exemple #8
0
    public override void OnInspectorGUI()
    {
        ETCJoystick t = (ETCJoystick)target;


        EditorGUILayout.Space();

        t.gameObject.name = EditorGUILayout.TextField("Joystick name", t.gameObject.name);
        t.activated       = ETCGuiTools.Toggle("Activated", t.activated, true);
        t.visible         = ETCGuiTools.Toggle("Visible", t.visible, true);

        EditorGUILayout.Space();
        t.useFixedUpdate        = ETCGuiTools.Toggle("Use Fixed Updae", t.useFixedUpdate, true);
        t.isUnregisterAtDisable = ETCGuiTools.Toggle("Unregister at disabling time", t.isUnregisterAtDisable, true);

        EditorGUILayout.Space();

        #region Type & Size
        t.showPSInspector = ETCGuiTools.BeginFoldOut("BronPoint & Size", t.showPSInspector);
        if (t.showPSInspector)
        {
            ETCGuiTools.BeginGroup(); {
                // Type
                t.joystickType = (ETCJoystick.JoystickType)EditorGUILayout.EnumPopup("Type", t.joystickType);

                if (t.joystickType == ETCJoystick.JoystickType.Static)
                {
                    t.anchor = (ETCBase.RectAnchor)EditorGUILayout.EnumPopup("Anchor", t.anchor);
                    if (t.anchor != ETCBase.RectAnchor.UserDefined)
                    {
                        t.anchorOffet = EditorGUILayout.Vector2Field("Offset", t.anchorOffet);
                    }

                    t.IsNoOffsetThumb = ETCGuiTools.Toggle("No offset thumb", t.IsNoOffsetThumb, true);

                    //	if (t.isNoOffsetThumb) t.isNoReturn = false;
                    t.IsNoReturnThumb = ETCGuiTools.Toggle("No return of the thumb", t.IsNoReturnThumb, true);
                }
                else if (t.joystickType == ETCJoystick.JoystickType.Dynamic)
                {
                    t.anchor = ETCBase.RectAnchor.UserDefined;
                    t.allowJoystickOverTouchPad = ETCGuiTools.Toggle("Allow over touchpad", t.allowJoystickOverTouchPad, true);
                    t.joystickArea = (ETCJoystick.JoystickArea)EditorGUILayout.EnumPopup("Joystick area", t.joystickArea);
                    if (t.joystickArea == ETCJoystick.JoystickArea.UserDefined)
                    {
                        t.userArea = (RectTransform)EditorGUILayout.ObjectField("User area", t.userArea, typeof(RectTransform), true);
                    }
                }

                EditorGUILayout.Space();

                // Area sprite ratio
                Rect  rect  = t.GetComponent <Image>().sprite.rect;
                float ratio = rect.width / rect.height;

                // Area Size
                if (ratio >= 1)
                {
                    float s = EditorGUILayout.FloatField("Background size", t.rectTransform().rect.width);
                    t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, s);
                    t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, s / ratio);
                }
                else
                {
                    float s = EditorGUILayout.FloatField("Background size", t.rectTransform().rect.height);
                    t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, s);
                    t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, s * ratio);
                }

                // Thumb sprite ratio
                rect  = t.thumb.GetComponent <Image>().sprite.rect;
                ratio = rect.width / rect.height;

                // Thumb size
                if (ratio >= 1)
                {
                    float s = EditorGUILayout.FloatField("Thumb size", t.thumb.rectTransform().rect.width);
                    t.thumb.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, s);
                    t.thumb.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, s / ratio);
                }
                else
                {
                    float s = EditorGUILayout.FloatField("Thumb size", t.thumb.rectTransform().rect.height);
                    t.thumb.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, s);
                    t.thumb.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, s * ratio);
                }

                EditorGUILayout.Space();

                t.radiusBase = (ETCJoystick.RadiusBase)EditorGUILayout.EnumPopup("Radius based on", t.radiusBase);
                if (t.radiusBase == ETCJoystick.RadiusBase.UserDefined)
                {
                    t.radiusBaseValue = EditorGUILayout.FloatField("Radius", t.radiusBaseValue);
                }
                EditorGUILayout.Space();
            } ETCGuiTools.EndGroup();
        }
        #endregion

        #region Axes properties
        t.showAxesInspector = ETCGuiTools.BeginFoldOut("Axes properties", t.showAxesInspector);
        if (t.showAxesInspector)
        {
            ETCGuiTools.BeginGroup(); {
                EditorGUILayout.Space();

                ETCGuiTools.BeginGroup(5); {
                    t.enableKeySimulation = ETCGuiTools.Toggle("Enable Unity axes", t.enableKeySimulation, true);
                    if (t.enableKeySimulation)
                    {
                        t.allowSimulationStandalone = ETCGuiTools.Toggle("Allow Unity axes on standalone", t.allowSimulationStandalone, true);
                        t.visibleOnStandalone       = ETCGuiTools.Toggle("Force visible", t.visibleOnStandalone, true);
                    }
                } ETCGuiTools.EndGroup();

                EditorGUILayout.Space();

                ETCGuiTools.BeginGroup(5); {
                    //t.isTurnAndMove = EditorGUILayout.ToggleLeft("Enable Turn & Move direction Action",t.isTurnAndMove);
                    t.isTurnAndMove = ETCGuiTools.Toggle("Turn & Move direction Action", t.isTurnAndMove, true, 220, true);
                    if (t.isTurnAndMove)
                    {
                        TurnAndMove(t.axisX, t.axisY, t);
                    }
                } ETCGuiTools.EndGroup();

                //EditorGUILayout.Space();

                ETCGuiTools.BeginGroup(5); {
                    ETCAxisInspector.AxisInspector(t.axisX, "Horizontal", ETCBase.ControlType.Joystick, t.isTurnAndMove, unityAxes);
                } ETCGuiTools.EndGroup();

                ETCGuiTools.BeginGroup(5); {
                    ETCAxisInspector.AxisInspector(t.axisY, "Vertical", ETCBase.ControlType.Joystick, t.isTurnAndMove, unityAxes);
                } ETCGuiTools.EndGroup();
            } ETCGuiTools.EndGroup();
        }
        #endregion

        #region Camera
        t.showCameraInspector = ETCGuiTools.BeginFoldOut("Camera", t.showCameraInspector);
        if (t.showCameraInspector)
        {
            ETCGuiTools.BeginGroup(); {
                EditorGUILayout.Space();
                t.enableCamera = ETCGuiTools.Toggle("Enable tracking", t.enableCamera, true);
                if (t.enableCamera)
                {
                    EditorGUILayout.Space();

                    // Auto link
                    ETCGuiTools.BeginGroup(5); {
                        t.autoLinkTagCam = EditorGUILayout.ToggleLeft("Auto link on tag", t.autoLinkTagCam);
                        if (t.autoLinkTagCam)
                        {
                            t.autoCamTag = EditorGUILayout.TagField("", t.autoCamTag);
                        }
                        else
                        {
                            t.cameraTransform = (Transform)EditorGUILayout.ObjectField("Camera", t.cameraTransform, typeof(Transform), true);
                        }
                    } ETCGuiTools.EndGroup();

                    EditorGUILayout.Space();

                    ETCGuiTools.BeginGroup(5); {
                        t.cameraTargetMode = (ETCJoystick.CameraTargetMode)EditorGUILayout.EnumPopup("Target mode", t.cameraTargetMode);
                        if (t.cameraTargetMode == ETCBase.CameraTargetMode.UserDefined)
                        {
                            t.cameraLookAt = (Transform)EditorGUILayout.ObjectField("Camera target", t.cameraLookAt, typeof(Transform), true);
                        }
                        if (t.cameraTargetMode == ETCBase.CameraTargetMode.LinkOnTag)
                        {
                            t.camTargetTag = EditorGUILayout.TagField("", t.camTargetTag);
                        }
                    } ETCGuiTools.EndGroup();

                    EditorGUILayout.Space();

                    ETCGuiTools.BeginGroup(5); {
                        t.cameraMode = (ETCJoystick.CameraMode)EditorGUILayout.EnumPopup("Camera mode", t.cameraMode);
                        switch (t.cameraMode)
                        {
                        case ETCJoystick.CameraMode.Follow:
                            t.followOffset = EditorGUILayout.Vector3Field("Offset", t.followOffset);
                            break;

                        case ETCJoystick.CameraMode.SmoothFollow:
                            t.enableWallDetection = EditorGUILayout.Toggle("Wall detection", t.enableWallDetection);
                            if (t.enableWallDetection)
                            {
                                SerializedObject   so    = new SerializedObject(t);
                                SerializedProperty layer = so.FindProperty("wallLayer");
                                EditorGUILayout.PropertyField(layer, true);
                                so.ApplyModifiedProperties();
                            }
                            EditorGUILayout.Space();
                            t.followDistance        = EditorGUILayout.FloatField("Distance", t.followDistance);
                            t.followHeight          = EditorGUILayout.FloatField("Height", t.followHeight);
                            t.followHeightDamping   = EditorGUILayout.FloatField("Height damping", t.followHeightDamping);
                            t.followRotationDamping = EditorGUILayout.FloatField("Rotation dampping", t.followRotationDamping);
                            break;
                        }
                    } ETCGuiTools.EndGroup();
                }
            } ETCGuiTools.EndGroup();
        }
        #endregion

        #region sprites
        t.showSpriteInspector = ETCGuiTools.BeginFoldOut("Sprites", t.showSpriteInspector);
        if (t.showSpriteInspector)
        {
            ETCGuiTools.BeginGroup(); {
                #region Background
                Sprite areaSprite = t.GetComponent <Image>().sprite;

                EditorGUILayout.BeginHorizontal();
                t.GetComponent <Image>().sprite = (Sprite)EditorGUILayout.ObjectField("Background", t.GetComponent <Image>().sprite, typeof(Sprite), true, GUILayout.MinWidth(100));
                t.GetComponent <Image>().color  = EditorGUILayout.ColorField("", t.GetComponent <Image>().color, GUILayout.Width(50));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
                Rect spriteRect = new Rect(areaSprite.rect.x / areaSprite.texture.width,
                                           areaSprite.rect.y / areaSprite.texture.height,
                                           areaSprite.rect.width / areaSprite.texture.width,
                                           areaSprite.rect.height / areaSprite.texture.height);
                GUILayout.Space(8);
                Rect lastRect = GUILayoutUtility.GetLastRect();
                lastRect.x      = 20;
                lastRect.width  = 100;
                lastRect.height = 100;

                GUILayout.Space(100);

                ETCGuiTools.DrawTextureRectPreview(lastRect, spriteRect, t.GetComponent <Image>().sprite.texture, Color.white);
                #endregion
                EditorGUILayout.Space();
                #region thumb
                Sprite thumbSprite = t.thumb.GetComponent <Image>().sprite;

                EditorGUILayout.BeginHorizontal();
                t.thumb.GetComponent <Image>().sprite = (Sprite)EditorGUILayout.ObjectField("Thumb", t.thumb.GetComponent <Image>().sprite, typeof(Sprite), true, GUILayout.MinWidth(100));
                t.thumb.GetComponent <Image>().color  = EditorGUILayout.ColorField("", t.thumb.GetComponent <Image>().color, GUILayout.Width(50));
                EditorGUILayout.EndHorizontal();

                spriteRect = new Rect(thumbSprite.rect.x / thumbSprite.texture.width,
                                      thumbSprite.rect.y / thumbSprite.texture.height,
                                      thumbSprite.rect.width / thumbSprite.texture.width,
                                      thumbSprite.rect.height / thumbSprite.texture.height);

                GUILayout.Space(8);
                lastRect        = GUILayoutUtility.GetLastRect();
                lastRect.x      = 20;
                lastRect.width  = 100;
                lastRect.height = 100;

                GUILayout.Space(100);

                ETCGuiTools.DrawTextureRectPreview(lastRect, spriteRect, t.thumb.GetComponent <Image>().sprite.texture, Color.white);

                #endregion
            } ETCGuiTools.EndGroup();
        }
        #endregion

        #region Events
        t.showEventInspector = ETCGuiTools.BeginFoldOut("Move Events", t.showEventInspector);
        if (t.showEventInspector)
        {
            ETCGuiTools.BeginGroup(); {
                serializedObject.Update();
                SerializedProperty moveStartEvent = serializedObject.FindProperty("onMoveStart");
                EditorGUILayout.PropertyField(moveStartEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveEvent = serializedObject.FindProperty("onMove");
                EditorGUILayout.PropertyField(moveEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveSpeedEvent = serializedObject.FindProperty("onMoveSpeed");
                EditorGUILayout.PropertyField(moveSpeedEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveEndEvent = serializedObject.FindProperty("onMoveEnd");
                EditorGUILayout.PropertyField(moveEndEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            } ETCGuiTools.EndGroup();
        }

        t.showTouchEventInspector = ETCGuiTools.BeginFoldOut("Touch Events", t.showTouchEventInspector);
        if (t.showTouchEventInspector)
        {
            ETCGuiTools.BeginGroup(); {
                serializedObject.Update();
                SerializedProperty touchStartEvent = serializedObject.FindProperty("onTouchStart");
                EditorGUILayout.PropertyField(touchStartEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty touchUpEvent = serializedObject.FindProperty("onTouchUp");
                EditorGUILayout.PropertyField(touchUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            } ETCGuiTools.EndGroup();
        }

        t.showDownEventInspector = ETCGuiTools.BeginFoldOut("Down Events", t.showDownEventInspector);
        if (t.showDownEventInspector)
        {
            ETCGuiTools.BeginGroup(); {
                serializedObject.Update();
                SerializedProperty downUpEvent = serializedObject.FindProperty("OnDownUp");
                EditorGUILayout.PropertyField(downUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downRightEvent = serializedObject.FindProperty("OnDownRight");
                EditorGUILayout.PropertyField(downRightEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downDownEvent = serializedObject.FindProperty("OnDownDown");
                EditorGUILayout.PropertyField(downDownEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downLeftEvent = serializedObject.FindProperty("OnDownLeft");
                EditorGUILayout.PropertyField(downLeftEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            } ETCGuiTools.EndGroup();
        }

        t.showPressEventInspector = ETCGuiTools.BeginFoldOut("Press Events", t.showPressEventInspector);
        if (t.showPressEventInspector)
        {
            ETCGuiTools.BeginGroup(); {
                serializedObject.Update();
                SerializedProperty pressUpEvent = serializedObject.FindProperty("OnPressUp");
                EditorGUILayout.PropertyField(pressUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressRightEvent = serializedObject.FindProperty("OnPressRight");
                EditorGUILayout.PropertyField(pressRightEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressDownEvent = serializedObject.FindProperty("OnPressDown");
                EditorGUILayout.PropertyField(pressDownEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressLeftEvent = serializedObject.FindProperty("OnPressLeft");
                EditorGUILayout.PropertyField(pressLeftEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            } ETCGuiTools.EndGroup();
        }

        #endregion

        if (t.anchor != ETCBase.RectAnchor.UserDefined && t.joystickType == ETCJoystick.JoystickType.Static)
        {
            t.SetAnchorPosition();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(t);
                        #if UNITY_5_3_OR_NEWER
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        #endif
        }
    }
Exemple #9
0
    static void printLightMapIndex()
    {
        TextureImporterFormat format = TextureImporterFormat.ASTC_RGBA_4x4;
        string root = AssetDatabase.GetAssetPath(Lightmapping.lightingDataAsset);

        root = root.Substring(0, root.LastIndexOf('/'));
        string        end1        = "_comp_shadowmask.png";
        string        end2        = "_comp_light.exr";
        var           s           = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        string        end3        = "_LightSM.tga";
        List <string> found_paths = new List <string>();

        int width  = 512;
        int height = 512;

        string [] paths = System.IO.Directory.GetFiles(root);
        Dictionary <int, string> lightMapTemp = new Dictionary <int, string>();
        int maxIndex = -1;

        for (int i = 0; i < paths.Length; i++)
        {
            string path = paths[i];
            if (path.EndsWith(end1))
            {
                string heater = path.Substring(0, path.Length - end1.Length);
                int    index  = int.Parse(heater.Substring(heater.LastIndexOf('-') + 1));
                maxIndex = Mathf.Max(index, maxIndex);
                string path2 = heater + end2;
                if (System.IO.File.Exists(path2))
                {
                    Texture2D t  = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
                    Texture2D t2 = AssetDatabase.LoadAssetAtPath <Texture2D>(path2);
                    found_paths.Add(path);
                    found_paths.Add(path2);
                    width  = t.width;
                    height = t.height;

                    RenderTexture rt  = RenderTexture.GetTemporary(t.width, t.height, 0);
                    Material      mat = new Material(Shader.Find("Hidden/HdrToHalfColor"));
                    mat.SetTexture("_MainTex", t2);
                    mat.SetTexture("_MainTex2", t);
                    Graphics.Blit(t2, rt, mat);

                    RenderTexture.active = rt;
                    Texture2D png = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
                    png.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);

                    byte[] bytes = EncodeToTGAExtension.EncodeToTGA(png, 4);
                    string path3 = heater + end3;
                    System.IO.File.WriteAllBytes(path3, bytes);

                    AssetDatabase.ImportAsset(path3);

                    TextureFormatHelper.ModifyTextureFormat(path3, "iPhone", format);
                    TextureFormatHelper.ModifyTextureFormat(path3, "Android", format);
                    TextureImporter texImporter = TextureImporter.GetAtPath(path3) as TextureImporter;
                    texImporter.isReadable = true;

                    GameObject.DestroyImmediate(png, true);

                    RenderTexture.ReleaseTemporary(rt);

                    GameObject.DestroyImmediate(t, false);
                    GameObject.DestroyImmediate(t2, false);;
                    lightMapTemp[index] = path3;
                }
            }
        }
        Texture2DArray texture2DArray = new Texture2DArray(width, height, maxIndex + 1, TextureFormat.ASTC_RGBA_4x4, true);


        foreach (var kp in lightMapTemp)
        {
            AssetDatabase.ImportAsset(kp.Value);
            Texture2D t = AssetDatabase.LoadAssetAtPath <Texture2D>(kp.Value);
            Graphics.CopyTexture(t, 0, texture2DArray, kp.Key);
            texture2DArray.Apply();
            GameObject.DestroyImmediate(t, true);
            AssetDatabase.DeleteAsset(kp.Value);
            //System.IO.File.Delete(kp.Value) ;
        }
        texture2DArray.wrapMode   = TextureWrapMode.Clamp;
        texture2DArray.filterMode = FilterMode.Bilinear;
        string arrayPath = root + "\\" + s.name + "_LMSM.asset";

        AssetDatabase.CreateAsset(texture2DArray, arrayPath);
        AssetDatabase.ImportAsset(arrayPath);
        ShadowMarkTex2dAry sma = GameObject.FindObjectOfType <ShadowMarkTex2dAry>();

        if (null == sma)
        {
            GameObject g = null;
            if (null != Camera.main)
            {
                g = Camera.main.gameObject;
            }
            else
            {
                g = new GameObject("Camera");
                g.AddComponent <Camera>();
            }
            sma = g.AddComponent <ShadowMarkTex2dAry>();
        }
        sma.shadowMark = AssetDatabase.LoadAssetAtPath <Texture2DArray>(arrayPath);

        AddCmpToRender();

        //Texture2D empty = new Texture2D(1, 1,TextureFormat.RGBA32,false);
        //empty.SetPixel(0, 0, Color.white);
        for (int i = 0; i < found_paths.Count; i++)
        {
            var str = found_paths[i];
            //System.IO.File.WriteAllBytes(str,empty.EncodeToPNG());
            //AssetDatabase.ImportAsset(str);
            AssetDatabase.DeleteAsset(str);
        }

        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
        //GameObject.DestroyImmediate(empty, true);
    }
Exemple #10
0
 public void Restart()
 {
     EditorSceneManager.LoadScene(EditorSceneManager.GetActiveScene().name);
 }
Exemple #11
0
        public static void CreateNewUI()
        {
#if UNITY_5
            var currentScene = EditorSceneManager.GetActiveScene().path;
#else
            var currentScene = EditorApplication.currentScene;
#endif
            GameObject mainCamera = GameObject.Find("Main Camera");
            if (mainCamera != null)
            {
                GameObject.DestroyImmediate(mainCamera);
            }

            var uiName = Path.GetFileNameWithoutExtension(currentScene);
            if (string.IsNullOrEmpty(uiName) || GameObject.Find(uiName) != null) // default use scene name, if exist create random name
            {
                uiName = "NewUI_" + Path.GetRandomFileName();
            }
            GameObject uiObj = new GameObject(uiName);
            uiObj.layer = (int)UnityLayerDef.UI;
            uiObj.AddComponent <UIWindowAsset>();

            var uiPanel = new GameObject("Image").AddComponent <Image>();
            uiPanel.transform.parent = uiObj.transform;
            KTool.ResetLocalTransform(uiPanel.transform);

            var canvas = uiObj.AddComponent <Canvas>();
            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            uiObj.AddComponent <CanvasScaler>();
            uiObj.AddComponent <GraphicRaycaster>();

            if (GameObject.Find("EventSystem") == null)
            {
                var evtSystemObj = new GameObject("EventSystem");
                evtSystemObj.AddComponent <EventSystem>();
                evtSystemObj.AddComponent <StandaloneInputModule>();
#if !UNITY_5
                evtSystemObj.AddComponent <TouchInputModule>();
#endif
            }

            if (GameObject.Find("Camera") == null)
            {
                GameObject cameraObj = new GameObject("Camera");
                cameraObj.layer = (int)UnityLayerDef.UI;

                Camera camera = cameraObj.AddComponent <Camera>();
                camera.clearFlags       = CameraClearFlags.Skybox;
                camera.depth            = 0;
                camera.backgroundColor  = Color.grey;
                camera.cullingMask      = 1 << (int)UnityLayerDef.UI;
                camera.orthographicSize = 1f;
                camera.orthographic     = true;
                camera.nearClipPlane    = -2f;
                camera.farClipPlane     = 2f;

                camera.gameObject.AddComponent <AudioListener>();
            }

            Selection.activeGameObject = uiObj;
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Space(10);

            #region Inspector

            GUILayout.BeginVertical("Easy Build System - Build Storage", "window", GUILayout.Height(10));

            GUILayout.BeginVertical("box");

            GUI.color = MainEditor.GetEditorColor;

            GUILayout.BeginHorizontal();

            GUILayout.Label("Build Storage Settings", EditorStyles.largeLabel);

            #region Build Storage Settings

            if (GUILayout.Button(DefaultInspector ? "Advanced Inspector" : "Default Inspector", GUILayout.Width(130)))
            {
                DefaultInspector = !DefaultInspector;
            }

            if (GUILayout.Button(AllIsOpen ? "Fold In" : "Fold Out", GUILayout.Width(80)))
            {
                BaseFoldout   = !BaseFoldout;
                AddonsFoldout = !AddonsFoldout;
                AllIsOpen     = !AllIsOpen;
            }

            if (GUILayout.Button(Help ? "Hide Help" : "Show Help", GUILayout.Width(100)))
            {
                Help = !Help;
            }

            GUI.color = Color.white;

            GUILayout.EndHorizontal();

            if (Help)
            {
                EditorGUILayout.HelpBox("This component allows to save and load all the Parts Behaviour of the scene before/after the runtime.\n" +
                                        "Note : The larger the number of parts saved in the file, please select Json in the serializer type field.", MessageType.Info);

                GUI.color = MainEditor.GetEditorColor;

                if (GUILayout.Button("Open Documentation Link"))
                {
                    Application.OpenURL(Constants.DOCS_LINK);
                }

                GUI.color = Color.white;
            }

            if (DefaultInspector)
            {
                DrawDefaultInspector();

                GUILayout.EndVertical();

                GUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                GUILayout.Space(10);

                return;
            }

            GUI.enabled = false;

            EditorGUILayout.ObjectField("Script", target, typeof(BuilderBehaviour), true);

            GUI.enabled = true;

            GUILayout.BeginHorizontal();

            GUILayout.Space(13);

            BaseFoldout = EditorGUILayout.Foldout(BaseFoldout, "Base Section Settings");

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Space(13);

            GUILayout.BeginVertical();

            if (BaseFoldout)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageType"), new GUIContent("Storage Type :", "This allows to save/load for Desktop or Android."));

                EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageSerializer"), new GUIContent("Storage Serializer Type :", "This allows to define the serializer type."));

                EditorGUILayout.PropertyField(serializedObject.FindProperty("AutoSave"), new GUIContent("Use Auto Save :", "This allows to enable auto save."));

                if (serializedObject.FindProperty("AutoSave").boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("AutoSaveInterval"), new GUIContent("Auto Save Interval (ms) :", "This allows to define the auto save interval."));
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty("SavePrefabs"), new GUIContent("Save All Part Behaviour :", "This allows to save all the prefabs after have exited the scene."));

                EditorGUILayout.PropertyField(serializedObject.FindProperty("LoadPrefabs"), new GUIContent("Load All Part Behaviour :", "This allows to save all the prefabs at startup of the scene."));

                if (serializedObject.FindProperty("StorageType").enumValueIndex == 0)
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.HelpBox("Define here the complete path with the name & extension.\n" +
                                            @"Example For Windows : C:\Users\My Dekstop\Desktop\MyFile.dat", MessageType.Info);

                    EditorGUILayout.PropertyField(serializedObject.FindProperty("StorageOutputFile"), new GUIContent("Storage Output Path :", "Output path to save and load the file."));

                    EditorGUI.EndChangeCheck();

                    if (GUI.changed)
                    {
                        EditorUtility.SetDirty(target);
                    }
                }

                GUI.color = MainEditor.GetEditorColor;

                if (GUILayout.Button("Load Storage File In Editor Scene ..."))
                {
                    if (EditorUtility.DisplayDialog("Easy Build System - Information", "(Only Large File) Note :\nYour scene will be saved, to avoid the loss of data in case of a crash of the editor.", "Load", "Cancel"))
                    {
                        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());

                        LoadPath = EditorUtility.OpenFilePanel("Load Ebs Storage File :", "", "*.*");

                        if (LoadPath != string.Empty)
                        {
                            Target.LoadInEditor(LoadPath);
                        }
                    }
                }

                GUILayout.EndVertical();

                GUILayout.BeginVertical("box");
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            #endregion Build Storage Settings

            GUI.color = MainEditor.GetEditorColor;

            GUILayout.Label("Build Storage Add-Ons Settings", EditorStyles.largeLabel);

            #region Socket Add-Ons Settings

            GUI.color = Color.white;

            GUILayout.BeginHorizontal();

            GUILayout.Space(13);

            AddonsFoldout = EditorGUILayout.Foldout(AddonsFoldout, "Add-Ons Section Settings");

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Space(13);

            GUILayout.BeginVertical();

            if (AddonsFoldout)
            {
                MainEditor.DrawAddons(Target, AddOnTarget.StorageBehaviour);
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            #endregion Socket Add-Ons Settings


            GUILayout.EndVertical();

            GUILayout.EndVertical();

            #endregion Inspector

            serializedObject.ApplyModifiedProperties();

            GUILayout.Space(10);
        }
    private void DrawSettings()
    {
        PupilSettings pupilSettings = PupilTools.Settings;

        GUILayout.Space(10);

        // test for changes in exposed values
        EditorGUI.BeginChangeCheck();
        pupilTracker.SettingsTab = GUILayout.Toolbar(pupilTracker.SettingsTab, new string[] {
            "pupil app",
            "calibration",
            "recording"
        }, GUILayout.Height(30));
        ////////INPUT FIELDS////////
        switch (pupilTracker.SettingsTab)
        {
        case 0:        //PUPIL APP
            if (PupilTools.Settings.DataProcessState == PupilSettings.EStatus.Calibration)
            {
                GUI.enabled = false;
            }

            GUILayout.Space(10);

            AutoRunLayout();

            GUILayout.Space(20);

            ////////////////////////////CONNECTION MODE////////////////////////////
            EditorGUI.BeginChangeCheck();
            //GUI.color = new Color (.7f, .7f, .7f, 1f);

            PupilTools.Settings.connection.isLocal = Convert.ToBoolean(GUILayout.Toolbar(Convert.ToInt32(PupilTools.Settings.connection.isLocal), new string[] {
                "Remote",
                "Local"
            }, GUILayout.Height(30), GUILayout.MinWidth(25)));
            //pupilTracker.customInspector.connectionMode = GUILayout.Toolbar (pupilTracker.customInspector.connectionMode, new string[]{ "Local", "Remote" }, GUILayout.Height (30), GUILayout.MinWidth (25));
            GUI.color = Color.white;
            if (EditorGUI.EndChangeCheck())
            {
                if (PupilTools.Settings.connection.isLocal)
                {
                    tempServerIP = PupilTools.Settings.connection.IP;
                    PupilTools.Settings.connection.IP = "127.0.0.1";
                }
                else
                {
                    PupilTools.Settings.connection.IP = tempServerIP;
                }
            }

            ////////////////////////////CONNECTION MODE////////////////////////////
            GUILayout.Space(5);
            if (PupilTools.Settings.connection.isLocal)              //LOCAL CONNECTION MODE//
            ////////////////////////////PUPIL APP PATH////////////////////////////
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("path : ", pupilSettings.GUIStyles[5], GUILayout.MinWidth(50));

                PupilTools.Settings.pupilServiceApp.servicePath = EditorGUILayout.TextArea(PupilTools.Settings.pupilServiceApp.servicePath, pupilSettings.GUIStyles[6], GUILayout.MinWidth(100), GUILayout.Height(22));
                if (GUILayout.Button("Browse"))
                {
                    PupilTools.Settings.pupilServiceApp.servicePath = EditorUtility.OpenFilePanel("Select Pupil service application file", PupilTools.Settings.pupilServiceApp.servicePath, "exe");
                }
                GUILayout.EndHorizontal();
                ////////////////////////////PUPIL APP PATH////////////////////////////
            }

            if (pupilSettings.customGUIVariables.bools.isAdvanced)             //ADVANCED SETTING

            ////////////////////////////SERVICE PORT////////////////////////////
            ///
            {
                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("Service Port : ", pupilSettings.GUIStyles[3], GUILayout.MinWidth(50));
                PupilTools.Settings.connection.PORT = EditorGUILayout.IntField(PupilTools.Settings.connection.PORT, pupilSettings.GUIStyles[4], GUILayout.MinWidth(100), GUILayout.Height(22));
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVICE PORT\////////////////////////////
                base.OnInspectorGUI();
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Separator Line
            }                                                                        //ADVANCED SETTING\

            if (!PupilTools.Settings.connection.isLocal)                             //---------REMOTE CONNECTION MODE---------//



            {
                GUILayout.Space(5);

                ////////////////////////////SERVER IP ADDRESS////////////////////////////
                ///

                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("IP : ", pupilSettings.GUIStyles[5], GUILayout.MinWidth(50));
                //

//				pupilTracker.Settings = (PupilSettings)EditorGUILayout.ObjectField (pupilTracker.Settings);
//				pupilTracker.Settings.a = EditorGUILayout.TextArea (pupilTracker.Settings.a, pupilTracker.Styles[8], GUILayout.MinWidth (50), GUILayout.Height (22));
                PupilTools.Settings.connection.IP = EditorGUILayout.TextArea(PupilTools.Settings.connection.IP, pupilSettings.GUIStyles[4], GUILayout.MinWidth(50), GUILayout.Height(22));
                if (GUILayout.Button("Default"))
                {
                    PupilTools.Settings.connection.IP = "127.0.0.1";
                    Repaint();
                    GUI.FocusControl("");
                }
                //
                GUI.enabled = true;
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVER IP ADDRESS\////////////////////////////


                GUI.enabled = true;
            }            //---------REMOTE CONNECTION MODE\---------//


            break;

        case 1:        //CALIBRATION


//			GUILayout.Space (20);
//
//			////////////////////////////2D-3D TOGGLE BAR////////////////////////////
//			EditorGUI.BeginChangeCheck ();
//			var calibrationMode = (Calibration.Mode)GUILayout.Toolbar ((int)pupilSettings.calibration.currentMode, new string[] {
//				"2D",
//				"3D"
//			});
//			if (calibrationMode != pupilSettings.calibration.currentMode)
//			{
//				pupilSettings.calibration.SetMode (calibrationMode);
//			}
//			GUI.enabled = true;
//			EditorGUI.EndChangeCheck ();
//			////////////////////////////2D-3D TOGGLE BAR////////////////////////////

            ////////////////////////////CALIBRATION DEBUG MODE////////////////////////////
            if (PupilTools.Settings.DataProcessState == PupilSettings.EStatus.Calibration || !isEyeProcessConnected || (int)pupilSettings.calibration.currentMode != 1)
            {
            }
            else
            {
                //GUI.enabled = false;

                EditorGUI.BeginChangeCheck();

                pupilSettings.debugView.active = GUILayout.Toggle(pupilSettings.debugView.active, "Calibration Debug Mode", "Button");
                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    if (pupilSettings.debugView.active)
                    {
                        if (pupilTracker.OperatorMonitorProperties [0].OperatorCamera != null)
                        {
                            OperatorMonitor.Instance.ExitOperatorMonitor();
                        }
                        pupilTracker.debugInstance.StartCalibrationDebugView();
                    }
                    else
                    {
                        pupilTracker.debugInstance.CloseCalibrationDebugView();
                    }
                }
            }

            if (pupilSettings.debugView.active)
            {
                //				pupilTracker.calibrationDebugCamera = (PupilGazeTracker.CalibrationDebugCamera) EditorGUILayout.EnumPopup (pupilTracker.calibrationDebugCamera);
                GUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                pupilTracker.debugInstance.DebugViewVariables.isDrawLines  = GUILayout.Toggle(pupilTracker.debugInstance.DebugViewVariables.isDrawLines, " Draw Debug Lines ", "Button");
                pupilTracker.debugInstance.DebugViewVariables.isDrawPoints = GUILayout.Toggle(pupilTracker.debugInstance.DebugViewVariables.isDrawPoints, " Draw Debug Points ", "Button");
                if (EditorGUI.EndChangeCheck())
                {
                    pupilTracker.debugInstance.SetDrawCalibrationPointCloud(pupilTracker.debugInstance.DebugViewVariables.isDrawPoints);
                    pupilTracker.debugInstance.SetDrawCalibrationLines(pupilTracker.debugInstance.DebugViewVariables.isDrawLines);
                }
                GUILayout.EndHorizontal();
            }

            GUI.enabled = true;
//			////////////////////////////CALIBRATION DEBUG MODE////////////////////////////
//
//			GUILayout.Space (20);
//
//			GUILayout.BeginHorizontal ();////////////////////HORIZONTAL////////////////////
//			GUILayout.Label ("Samples per depth", pupilSettings.GUIStyles[3], GUILayout.MinWidth (35));
//			pupilSettings.calibration.currentCalibrationType.samplesPerDepth = EditorGUILayout.IntSlider (pupilSettings.calibration.currentCalibrationType.samplesPerDepth, 1, 120, GUILayout.ExpandWidth(true));
//			GUILayout.EndHorizontal ();////////////////////HORIZONTAL////////////////////

            GUILayout.Space(10);             //------------------------------------------------------------//

            if (pupilSettings.customGUIVariables.bools.isAdvanced)
            {
                base.OnInspectorGUI();
            }
            break;

        case 2:        //RECORDING

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();
            PupilTools.Settings.recorder.resolution = (FFmpegOut.FFmpegPipe.Resolution)EditorGUILayout.EnumPopup(PupilTools.Settings.recorder.resolution);
            PupilTools.Settings.recorder.codec      = (FFmpegOut.FFmpegPipe.Codec)EditorGUILayout.EnumPopup(PupilTools.Settings.recorder.codec);        //  GUILayout.Toolbar (pupilTracker.Codec, new string[] {
            GUILayout.EndHorizontal();

//			GUILayout.BeginHorizontal ();
//			PupilTools.Settings.recorder.isFixedRecordingLength = GUILayout.Toggle (PupilTools.Settings.recorder.isFixedRecordingLength, "fixed length", "Button", GUILayout.Width (90));
//			if (PupilTools.Settings.recorder.isFixedRecordingLength) {
//				PupilTools.Settings.recorder.recordingLength = EditorGUILayout.FloatField (PupilTools.Settings.recorder.recordingLength);
//			}
//			GUILayout.EndHorizontal ();

            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            PupilTools.Settings.recorder.isCustomPath = GUILayout.Toggle(PupilTools.Settings.recorder.isCustomPath, "CustomPath", "Button", GUILayout.Width(90));
            if (EditorGUI.EndChangeCheck())
            {
                if (PupilTools.Settings.recorder.isCustomPath)
                {
                    PupilTools.Settings.recorder.filePath = EditorUtility.OpenFolderPanel("Select the output folder", PupilTools.Settings.recorder.filePath, "");
                }
            }
            if (PupilTools.Settings.recorder.isCustomPath)
            {
                GUIStyle centeredStyle = new GUIStyle(GUI.skin.textField);
                centeredStyle.alignment               = TextAnchor.MiddleCenter;
                centeredStyle.margin                  = new RectOffset(0, 0, 3, 0);
                centeredStyle.fixedHeight             = 20;
                PupilTools.Settings.recorder.filePath = GUILayout.TextField(PupilTools.Settings.recorder.filePath, centeredStyle);
                if (GUILayout.Button("Browse", GUILayout.Width(60)))
                {
                    PupilTools.Settings.recorder.filePath = EditorUtility.OpenFolderPanel("Select the output folder", PupilTools.Settings.recorder.filePath, "");
                }
            }
            GUILayout.EndHorizontal();

            break;
        }


        //if change found set scene as dirty, so user will have to save changed values.
        if (EditorGUI.EndChangeCheck() && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        GUILayout.Space(10);
    }
    public override void OnInspectorGUI()
    {
        DatabaseManager myTarget = null;

        try { myTarget = (DatabaseManager)target; } catch { }

        if (myTarget != null)
        {
            GUI.changed = false;

            EditorStyles.label.fontStyle = FontStyle.Bold;
            EditorGUILayout.LabelField("DATABASE CONFIGURATION");
            EditorStyles.label.fontStyle = FontStyle.Normal;
            myTarget.DatabaseType        = (ClsDAL.DBtypes)EditorGUILayout.EnumPopup("Database Type", myTarget.DatabaseType);

            EditorGUILayout.Separator();
            EditorGUILayout.Space();
            switch (myTarget.DatabaseType)
            {
            case ClsDAL.DBtypes.MSSQL:
            case ClsDAL.DBtypes.MYSQL:
                myTarget.DBtextFile = (TextAsset)EditorGUILayout.ObjectField("Override File", myTarget.DBtextFile, typeof(TextAsset), true);
                myTarget.DBserver   = EditorGUILayout.TextField("Database Server", myTarget.DBserver);
                myTarget.DBport     = EditorGUILayout.IntField("Database Port", myTarget.DBport);
                myTarget.DBdatabase = EditorGUILayout.TextField("Database Name", myTarget.DBdatabase);
                if (myTarget.DatabaseType == ClsDAL.DBtypes.MSSQL)
                {
                    myTarget.DBuseWindowsAccount = EditorGUILayout.Toggle("Use Windows Account", myTarget.DBuseWindowsAccount);
                }
                else
                {
                    myTarget.DBuseWindowsAccount = false;
                }
                if (myTarget.DBport < 1)
                {
                    myTarget.DBport = (myTarget.DatabaseType == ClsDAL.DBtypes.MSSQL) ? 1433 : 3306;
                }
                if (!myTarget.DBuseWindowsAccount)
                {
                    myTarget.DBuser     = EditorGUILayout.TextField("Username", myTarget.DBuser);
                    myTarget.DBpassword = EditorGUILayout.PasswordField("Password", myTarget.DBpassword);                                                                                                                       // PasswordField
                }
                break;

            case ClsDAL.DBtypes.SQLITE:
                myTarget.SQLiteDBfileLocation = EditorGUILayout.TextField("Database File", myTarget.SQLiteDBfileLocation);
                break;
            }

            EditorGUILayout.Separator();
            EditorGUILayout.Space();
            myTarget.KeepConnectionOpen = EditorGUILayout.Toggle("Keep Connection Open", myTarget.KeepConnectionOpen);
            myTarget.ClientsCanUse      = EditorGUILayout.Toggle("Client Can Use DB", myTarget.ClientsCanUse);


            if (myTarget.DatabaseType == ClsDAL.DBtypes.MSSQL)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Space();
                EditorGUILayout.TextField("Encrypted Text", strDec, GUILayout.MaxHeight(75));
                if (GUILayout.Button("Show Encryption Text"))
                {
                    strDec  = "";
                    strDec += "Server: " + myTarget.DBserver + "," + myTarget.DBport.ToString() + "\n";
                    strDec += "Database: " + myTarget.DBdatabase + "\n";
                    strDec += "Username: "******"\n";
                    strDec += "Password: "******"\n";
                }
            }

            if (Application.isPlaying)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Space();
                EditorStyles.label.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("DATABASE STATUS");
                EditorStyles.label.fontStyle = FontStyle.Normal;
                EditorGUILayout.Toggle("Is Online?", myTarget.IsConnectedCheck);

                EditorGUILayout.LabelField("Last Query: ", myTarget.DAL.LastQueryTime.ToString("0.000000") + " seconds");
                EditorGUILayout.LabelField("Average Query: ", myTarget.DAL.AverageQueryTime.ToString("0.000000") + " seconds");
                EditorGUILayout.Space();

                EditorStyles.label.wordWrap      = true;
                EditorStyles.label.stretchWidth  = false;
                EditorStyles.label.stretchHeight = true;
                EditorGUILayout.LabelField("Last Command", (myTarget.DAL.SQLqueries == "") ? "(None)" : myTarget.DAL.SQLqueries);
                EditorGUILayout.LabelField("Error Message", (myTarget.DAL.Errors == "")                 ? "(None)" : myTarget.DAL.Errors);
                EditorStyles.label.wordWrap      = false;
                EditorStyles.label.stretchHeight = false;
                if (GUILayout.Button("Reset SQL Errors"))
                {
                    myTarget.DAL.ResetErrors();
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(myTarget);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
    }