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

            EditorGUILayout.PropertyField(serializedObject.FindProperty("ChaseTarget"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("TargetForward"));
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("ControlPosition"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("ControlRotation"));
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("InputSetting"), true);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("AdvanceSetting"), true);

            EditorGUILayout.Separator();
            if (self != null && self.PresetList.Count > 0 && self.Selected < self.PresetList.Count && self.PresetList[self.Selected] != null)
            {
                EditorGUILayout.HelpBox("Camera : " + self.PresetList[self.Selected].name, MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("Camera : None", MessageType.Warning);
                self.Selected = 0;
            }
            EditorGUI.BeginChangeCheck();
            self.Selected = EditorGUILayout.IntSlider("Default Camera", self.Selected, 0, self.PresetList.Count - 1);
            if (EditorGUI.EndChangeCheck())
            {
                self.OnValidate();
            }
            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("All"))
            {
                foreach (Preset obj in self.PresetList)
                {
                    obj.m_DisplayOnScene = true;
                }
                EditorUtility.SetDirty(self);
            }
            if (GUILayout.Button("Toggle All"))
            {
                foreach (Preset obj in self.PresetList)
                {
                    obj.m_DisplayOnScene = !obj.m_DisplayOnScene;
                }
                EditorUtility.SetDirty(self);
            }
            EditorGUILayout.EndHorizontal();

            DrawCameraPresetList();

            DrawControllerSet();

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
示例#2
0
        private void OnCameraBotGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Preset preset = PropertyExtend.GetCurrent(property) as Preset;

            if (preset == null && property.serializedObject.targetObject is CameraBot)
            {
                CameraBot self = property.serializedObject.targetObject as CameraBot;
                self.OnValidate();
                return;
            }
            SerializedObject presetObj = new SerializedObject(preset);

            presetObj.Update();

            EditorGUI.BeginProperty(position, label, property);

            Rect line = position.Clone(height: lineH);

            Rect[] cells = line.SplitHorizontal(.1f, 50, 70);

            // First line
            if (GUI.Button(cells[0], (preset.m_DisplayOnScene ? "Show" : "Hide")))
            {
                preset.m_DisplayOnScene = !preset.m_DisplayOnScene;
            }

            cells = cells[1].Modify(x: 20f, width: -20f).SplitHorizontal(.85f);
            property.isExpanded = EditorGUI.Foldout(cells[0].Modify(), property.isExpanded, ((!property.isExpanded) ? preset.gameObject.name : ""));
            preset.m_DebugColor = EditorGUI.ColorField(cells[1], GUIContent.none, preset.m_DebugColor);

            if (property.isExpanded)
            {
                line = line.GetRectBottom(height: lineH).Modify(y: lineS);
                preset.gameObject.name = EditorGUI.TextField(line, preset.gameObject.name);

                SerializedProperty virtualPositionProp = presetObj.FindProperty("m_VirtualPosition");
                line = line.GetRectBottom(height: VirtualPositionDrawer.GetStaticHeight(virtualPositionProp)).Modify(y: lineS);
                EditorGUI.PropertyField(line, virtualPositionProp, true);

                SerializedProperty zoomProp = presetObj.FindProperty("m_Zoom");
                line = line.GetRectBottom(height: ZoomDrawer.GetStaticHeight(zoomProp)).Modify(y: lineS);
                EditorGUI.PropertyField(line, zoomProp, true);

                SerializedProperty clampAngleProp = presetObj.FindProperty("m_ClampAngle");
                line = line.GetRectBottom(height: ClampAngleDrawer.GetStaticHeight(clampAngleProp)).Modify(y: lineS);
                EditorGUI.PropertyField(line, clampAngleProp, true);

                SerializedProperty methodProp = presetObj.FindProperty("m_Method");
                line = line.GetRectBottom(height: MethodDrawer.GetStaticHeight(methodProp)).Modify(y: lineS);
                EditorGUI.PropertyField(line, methodProp, true);

                SerializedProperty positionOverriderProp = presetObj.FindProperty("m_PositionOverrider");
                line = line.GetRectBottom(height: PositionOverriderDrawer.GetStaticHeight(positionOverriderProp)).Modify(y: lineS);
                EditorGUI.PropertyField(line, positionOverriderProp, true);
            }


            presetObj.ApplyModifiedProperties();
            EditorGUI.EndProperty();
        }