Exemplo n.º 1
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                EditorGUI.BeginChangeCheck();

                // This will show the current used script and make it clickable. When clicked, the script's code is open into the default editor.
                EditorGUI.BeginDisabledGroup(true);
                {
                    script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                }
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUI.indentLevel++;
                    OptionFoldout = EditorGUILayout.Foldout(OptionFoldout, "Options");
                    EditorGUI.indentLevel--;

                    if (OptionFoldout)
                    {
                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            EditorGUILayout.PropertyField(key, new GUIContent("Data key", "Redis data key holding intrinsics parameters informations."), GUILayout.MinWidth(50));
                            if (GUILayout.Button(new GUIContent("T", "Test if the key contains data."), EditorStyles.miniButton, GUILayout.Width(18)))
                            {
                                if (S.state != ServiceStatus.DISCONNECTED)
                                {
                                    S.init();
                                }
                            }
                            NatarEditor.DrawServiceStatus(S.state);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginVertical(NatarEditor.FlatBox);
                    {
                        EditorGUI.indentLevel++;
                        MatrixFoldout = EditorGUILayout.Foldout(MatrixFoldout, "Intrinsics matrix");
                        EditorGUI.indentLevel--;

                        if (MatrixFoldout)
                        {
                            Matrix4x4 m = S.GetProjectionMatrix();
                            NatarEditor.DrawMatrix4x4(m);
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    // When a property is accessed directly from script instead of via serialized properties
                    // pressing play causes the property to reset to its original value.
                    // Setting the target dirty prevent this effect
                    Undo.RecordObject(target, "SetupIntrinsics values changed");
                    EditorUtility.SetDirty(target);
                }
            }
Exemplo n.º 2
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                EditorGUI.BeginChangeCheck();

                EditorGUI.BeginDisabledGroup(true);
                {
                    script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                }
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUI.indentLevel++;
                    OptionFoldout = EditorGUILayout.Foldout(OptionFoldout, "Options");
                    EditorGUI.indentLevel--;

                    if (OptionFoldout)
                    {
                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            EditorGUILayout.PropertyField(key, new GUIContent("Data key", "Redis data key holding intrinsics parameters informations."), GUILayout.MinWidth(50));
                            if (GUILayout.Button(new GUIContent("T", "Test if the key contains data."), EditorStyles.miniButton, GUILayout.Width(18)))
                            {
                                if (C.state != ServiceStatus.DISCONNECTED)
                                {
                                    C.init();
                                }
                            }
                            NatarEditor.DrawServiceStatus(C.state);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            EditorGUILayout.PropertyField(outImage, new GUIContent("Out image", ""), GUILayout.MinWidth(50));
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            GUILayout.FlexibleSpace();
                            Texture2D tex = C.GetCurrentTexture();
                            if (tex != null)
                            {
                                NatarEditor.DrawTexture(tex);
                            }
                            else
                            {
                                GUILayout.Label("No preview available.");
                            }
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    // When a property is accessed directly from script instead of via serialized properties
                    // pressing play causes the property to reset to its original value.
                    // Setting the target dirty prevent this effect
                    Undo.RecordObject(target, "CameraPlayback values changed");
                    EditorUtility.SetDirty(target);
                }
            }
Exemplo n.º 3
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                EditorGUI.BeginChangeCheck();

                // This will show the current used script and make it clickable. When clicked, the script's code is open into the default editor.
                EditorGUI.BeginDisabledGroup(true);
                script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUI.indentLevel++;
                SettingsFoldout = EditorGUILayout.Foldout(SettingsFoldout, "Options");
                EditorGUI.indentLevel--;

                if (SettingsFoldout)
                {
                    EditorGUILayout.BeginVertical(NatarEditor.FlatBox);
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PropertyField(RedisServerHost, new GUIContent("Connection settings", "Input ip adress and host" +
                                                                                          "\nSupported IP formats are the following:" +
                                                                                          "\n127.0.0.1" +
                                                                                          "\nlocalhost" +
                                                                                          "\nhttp://127.0.0.1" +
                                                                                          "\nhttp://host-example.com"), GUILayout.MinWidth(48));
                            EditorGUIUtility.labelWidth = 18;
                            EditorGUILayout.PropertyField(RedisServerPort, new GUIContent("", "Port"), GUILayout.MaxWidth(35));
                            EditorGUIUtility.labelWidth = 0;
                            R.NoDelaySocket             = GUILayout.Toggle(R.NoDelaySocket, new GUIContent("D", "Toggle no delay sockets for this connection."), EditorStyles.miniButton, GUILayout.Width(18));

                            if (R.IsConnected())
                            {
                                NatarEditor.DrawServiceStatus(ServiceStatus.WORKING);
                            }
                            else
                            {
                                NatarEditor.DrawServiceStatus(ServiceStatus.DISCONNECTED);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(NatarEditor.FlatBox);
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PropertyField(PingLatency, new GUIContent("Ping delay (ms)", "Ping the redis server to ensure that it is alive." +
                                                                                      "\nToo short value may cause lags or even crashes while higher values can lead to unexpected behavior when a Redis server is disconnected while services are still running."));
                            if (GUILayout.Button(new GUIContent("Ping", "Manually ping the service to check its state."), EditorStyles.miniButton, GUILayout.MaxWidth(30)))
                            {
                                R.Ping();
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    // When a property is accessed directly from script instead of via serialized properties
                    // pressing play causes the property to reset to its original value.
                    // Setting the target dirty prevent this effect
                    Undo.RecordObject(target, "RedisHandler values changed");
                    EditorUtility.SetDirty(target);
                }
            }
Exemplo n.º 4
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                EditorGUI.BeginChangeCheck();

                EditorGUI.BeginDisabledGroup(true);
                {
                    script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                }
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUI.indentLevel++;
                    OptionFoldout = EditorGUILayout.Foldout(OptionFoldout, "Options");
                    EditorGUI.indentLevel--;

                    if (OptionFoldout)
                    {
                        #region datakey
                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            EditorGUILayout.PropertyField(key, new GUIContent("Data key", "Redis data key holding intrinsics parameters informations."), GUILayout.MinWidth(50));
                            if (GUILayout.Button(new GUIContent("T", "Test if the key contains data."), EditorStyles.miniButton, GUILayout.Width(18)))
                            {
                                if (T.state != ServiceStatus.DISCONNECTED)
                                {
                                    T.init();
                                }
                            }
                            NatarEditor.DrawServiceStatus(T.state);
                        }
                        EditorGUILayout.EndHorizontal();
                        #endregion

                        #region targetmodel
                        EditorGUILayout.BeginVertical(NatarEditor.FlatBox);
                        {
                            EditorGUILayout.PropertyField(targetModel, new GUIContent("Target model", "3D model to apply the texture to."));
                            if (T.targetModel == null)
                            {
                                EditorGUILayout.BeginVertical(NatarEditor.StyleRed);
                                {
                                    EditorGUILayout.HelpBox("The target model is required for the component to work.", MessageType.None, true);
                                }
                                EditorGUILayout.EndVertical();
                            }
                            else if (T.targetModel.GetComponent <Renderer>() == null)
                            {
                                EditorGUILayout.BeginVertical(NatarEditor.StyleOrange);
                                {
                                    EditorGUILayout.HelpBox("The target model must have a material in order for the texture to be set.", MessageType.None, true);
                                }
                                EditorGUILayout.EndVertical();
                            }
                        }
                        EditorGUILayout.EndVertical();
                        #endregion

                        #region texture
                        EditorGUILayout.BeginHorizontal(NatarEditor.FlatBox);
                        {
                            GUILayout.FlexibleSpace();
                            Texture2D tex = T.GetCurrentTexture();
                            if (tex != null)
                            {
                                NatarEditor.DrawTexture(tex);
                            }
                            else
                            {
                                GUILayout.Label("No preview available.");
                            }
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndHorizontal();
                        #endregion
                    }
                }
                EditorGUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    // When a property is accessed directly from script instead of via serialized properties
                    // pressing play causes the property to reset to its original value.
                    // Setting the target dirty prevent this effect
                    Undo.RecordObject(target, "Texturer values changed");
                    EditorUtility.SetDirty(target);
                }
            }