protected internal override void RenderContents(HtmlTextWriter writer)
        {
            if (Page != null)
            {
                Page.VerifyRenderingInServerForm(this);
            }

            // HACK: Need this for child controls to be created at design-time when control is inside template
            EnsureChildControls();

            string[] propertyDisplayNames = null;
            string[] propertyDescriptions = null;
            object   editableObject       = GetEditableObject();

            if (editableObject != null)
            {
                PropertyDescriptorCollection propDescs = GetEditableProperties(editableObject, true);
                propertyDisplayNames = new string[propDescs.Count];
                propertyDescriptions = new string[propDescs.Count];
                for (int i = 0; i < propDescs.Count; i++)
                {
                    propertyDisplayNames[i] = GetDisplayName(propDescs[i]);
                    propertyDescriptions[i] = GetDescription(propDescs[i]);
                }
            }

            if (propertyDisplayNames != null)
            {
                WebControl[] editorControls = (WebControl[])EditorControls.ToArray(typeof(WebControl));
                Debug.Assert(propertyDisplayNames.Length == editorControls.Length && propertyDisplayNames.Length == _errorMessages.Length);
                RenderPropertyEditors(writer, propertyDisplayNames, propertyDescriptions, editorControls, _errorMessages);
            }
        }
        protected internal override void CreateChildControls()
        {
            ControlCollection controls = Controls;

            controls.Clear();
            EditorControls.Clear();

            object editableObject = GetEditableObject();

            if (editableObject != null)
            {
                foreach (PropertyDescriptor pd in GetEditableProperties(editableObject, true))
                {
                    Control editorControl = CreateEditorControl(pd);
                    EditorControls.Add(editorControl);
                    Controls.Add(editorControl);
                }
                _errorMessages = new string[EditorControls.Count];
            }

            // We don't need viewstate enabled on our child controls.  Disable for perf.
            foreach (Control c in controls)
            {
                c.EnableViewState = false;
            }
        }
Esempio n. 3
0
 void Awake()
 {
     if (controls == null)
     {
         controls = this;
     }
     else
     {
         DestroyImmediate(this.gameObject);
     }
 }
Esempio n. 4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        EditorControls levelRoot = (EditorControls)target;

        if (GUILayout.Button("Export Level"))
        {
            levelRoot.ExportLevel();
        }

        if (GUILayout.Button("Load Level"))
        {
            levelRoot.LoadLevel("");
        }
    }
Esempio n. 5
0
        // Internals //////////////////////////////////////////////////////////////
        private void CollectEditableProperties(object editableObject)
        {
            _groupProperties = new Dictionary <string, List <PropertyDescriptor> >();

            var controls = Controls;

            controls.Clear();
            EditorControls.Clear();
            controls.Add(new PlaceHolder());
            var properties = GetEditableProperties(editableObject);

            // grouping
            foreach (PropertyDescriptor descriptor in properties)
            {
                if ((this.HiddenProperties != null) && (this.HiddenProperties.Contains(descriptor.Name)))
                {
                    continue;
                }

                var categoryTitle = GetCategoryTitle(descriptor);
                if (HiddenCategories == null || !HiddenCategories.Contains(categoryTitle))
                {
                    if (!String.IsNullOrEmpty(categoryTitle))
                    {
                        List <PropertyDescriptor> categoryValue = null;
                        categoryValue = _groupProperties.ContainsKey(categoryTitle) ? _groupProperties[categoryTitle] : new List <PropertyDescriptor>();

                        categoryValue.Add(descriptor);
                        if (!_groupProperties.ContainsKey(categoryTitle))
                        {
                            _groupProperties.Add(categoryTitle, categoryValue);
                        }
                    }
                }

                if (_categories.Contains(categoryTitle) || String.IsNullOrEmpty(categoryTitle))
                {
                    continue;
                }
                _categories.Add(categoryTitle);
            }

            // create controls
            var editorControls = new PlaceHolder {
                ID = "GroupProperties", EnableViewState = false
            };

            foreach (var entry in _groupProperties)
            {
                var title = entry.Key;
                entry.Value.Sort(new WebOrderComparer());
                var descriptors = entry.Value;

                if (String.IsNullOrEmpty(title) || descriptors == null)
                {
                    continue;
                }

                var groupControl = new PropertyFieldPanel {
                    Title = title
                };
                groupControl.EnableViewState = false;
                foreach (var descriptor in descriptors)
                {
                    var editorControl = CreateEditorControl(descriptor);
                    if (editorControl == null)
                    {
                        continue;
                    }
                    editorControl.EnableViewState = false;
                    groupControl.Controls.Add(editorControl);
                }
                if (groupControl.Controls.Count > 0)
                {
                    editorControls.Controls.Add(groupControl);
                }
            }
            if (editorControls.Controls.Count == 0)
            {
                return;
            }
            EditorControls.Add(editorControls);
            controls.Add(editorControls);
        }
 static void ZeroObjectsPosition()
 {
     EditorControls.ZeroSelectedObjectsPosition();
 }
 static void RemoveParents()
 {
     EditorControls.RemoveParentsOfSelectedObjects();
 }
 static void GroupObjects()
 {
     EditorControls.GroupSelectedObjects();
 }