Esempio n. 1
0
        /// <summary>
        /// Draws the target object.
        /// </summary>
        /// <param name="_control">Control.</param>
        /// <param name="_target">Target.</param>
        /// <param name="_title">Title.</param>
        /// <param name="_help">Help.</param>
        public static void DrawTargetObject(ICECreatureControl _control, TargetObject _target, string _title, string _help = "")
        {
            if (_control == null || _target == null)
            {
                return;
            }

            _target.SetIsPrefab(EditorTools.IsPrefab(_target.TargetGameObject));

            // PREPARATION END

            if (!Application.isPlaying && !EditorTools.IsPrefab(_control.gameObject))
            {
                // TARGET OBJECT LINE BEGIN
                ICEEditorLayout.BeginHorizontal();

                if (_target.TargetGameObject == null)
                {
                    GUI.backgroundColor = Color.red;
                }
                else if (_target.Active)
                {
                    GUI.backgroundColor = Color.green;
                }

                string _target_title = "Target Object " + (_target.IsValid?(_target.IsPrefab?"(prefab)":"(scene)"):"(null)");

                if (_target.AccessType == TargetAccessType.NAME)
                {
                    _target.SetTargetByName(Popups.TargetPopup(_target_title, "", _target.TargetName, ""));
                }
                else if (_target.AccessType == TargetAccessType.TAG)
                {
                    _target.SetTargetByTag(EditorGUILayout.TagField(new GUIContent(_target_title, ""), _target.TargetTag));
                }
                else if (_target.AccessType == TargetAccessType.TYPE)
                {
                    _target.SetTargetByType((EntityClassType)EditorGUILayout.EnumPopup(new GUIContent(_target_title, ""), _target.TargetEntityType));
                }
                else
                {
                    _target.SetTargetByGameObject((GameObject)EditorGUILayout.ObjectField(_target_title, _target.TargetGameObject, typeof(GameObject), true));
                }


                GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor;

                // Type Enum Popup
                int _indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                _target.AccessType    = (TargetAccessType)EditorGUILayout.EnumPopup(_target.AccessType, ICEEditorStyle.Popup, GUILayout.Width(50));
                EditorGUI.indentLevel = _indent;


                if (_target.TargetGameObject != null)
                {
                    ICEEditorLayout.ButtonDisplayObject(_target.TargetGameObject.transform.position);
                    ICEEditorLayout.ButtonSelectObject(_target.TargetGameObject, ICEEditorStyle.CMDButtonDouble);

                    //_target.UseChildObjects = ICEEditorLayout.CheckButtonSmall( "CHD", "Allows the selection of own child objects", _target.UseChildObjects, ICEEditorLayout.SelectionOptionGroup3Color, ICEEditorLayout.SelectionOptionGroup3SelectedColor );

                    //if( _target.TargetGameObject.GetComponent<ICECreatureTargetAttribute>() != null )
                    {
                        EditorGUI.BeginDisabledGroup(_target.ReadTargetAttributeData() == null);
                        GUI.backgroundColor = Color.green;
                        if (ICEEditorLayout.ButtonSmall("TAV", "Use target attribute values"))
                        {
                            _target.SetTargetDefaultValues(_target.ReadTargetAttributeData());
                        }
                        GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor;
                        EditorGUI.EndDisabledGroup();
                    }
                }
                else
                {
                    if (ICEEditorLayout.AutoButton("Creates an empty GameObject as target with default settings"))
                    {
                        WizardEditor.WizardRandomTarget(_control, _target);
                    }
                }

                ICEEditorLayout.EndHorizontal(Info.TARGET_OBJECT);
                // TARGET OBJECT LINE END
            }
            else
            {
                DrawTargetObjectBlind(_target);
            }
        }