public void BuildEditor()
        {
            foreach (Transform t in EditorsPanel)
            {
                Destroy(t.gameObject);
            }

            IMaterialDescriptor selector;

            if (!m_propertySelectors.TryGetValue(Material.shader.name, out selector))
            {
                selector = new MaterialDescriptor();
            }


            object converter = selector.CreateConverter(this);

            MaterialPropertyDescriptor[] descriptors = selector.GetProperties(this, converter);
            if (descriptors == null)
            {
                Destroy(gameObject);
                return;
            }

            for (int i = 0; i < descriptors.Length; ++i)
            {
                MaterialPropertyDescriptor descriptor = descriptors[i];
                PropertyEditor             editor     = null;
                object       target       = descriptor.Target;
                PropertyInfo propertyInfo = descriptor.PropertyInfo;
#if !UNITY_WEBGL && PROC_MATERIAL
                if (descriptor.ProceduralDescription == null)
#endif
                {
                    RTShaderPropertyType propertyType = descriptor.Type;

                    switch (propertyType)
                    {
                    case RTShaderPropertyType.Range:
                        if (RangeEditor != null)
                        {
                            RangeEditor range = Instantiate(RangeEditor);
                            range.transform.SetParent(EditorsPanel, false);

                            var rangeLimits = descriptor.Limits;
                            range.Min = rangeLimits.Min;
                            range.Max = rangeLimits.Max;
                            editor    = range;
                        }
                        break;

                    default:
                        if (EditorsMap.IsPropertyEditorEnabled(propertyInfo.PropertyType))
                        {
                            GameObject editorPrefab = EditorsMap.GetPropertyEditor(propertyInfo.PropertyType);
                            GameObject instance     = Instantiate(editorPrefab);
                            instance.transform.SetParent(EditorsPanel, false);

                            if (instance != null)
                            {
                                editor = instance.GetComponent <PropertyEditor>();
                            }
                        }
                        break;
                    }
                }
#if !UNITY_WEBGL && PROC_MATERIAL
                else
                {
                    ProcPropertyDescription input = descriptor.ProceduralDescription;
                    if (input.hasRange)
                    {
                        if (input.type == ProcPropertyType.Float)
                        {
                            if (RangeEditor != null)
                            {
                                RangeEditor range = Instantiate(RangeEditor);
                                range.transform.SetParent(EditorsPanel, false);
                                range.Min = input.minimum;
                                range.Max = input.maximum;
                                //TODO implement step on range editor // = input.step
                                editor = range;
                            }
                        }
                        else
                        {
                            //TODO: Implement range on vector editors

                            if (EditorsMap.IsPropertyEditorEnabled(propertyInfo.PropertyType))
                            {
                                GameObject editorPrefab = EditorsMap.GetPropertyEditor(propertyInfo.PropertyType);
                                GameObject instance     = Instantiate(editorPrefab);
                                instance.transform.SetParent(EditorsPanel, false);

                                if (instance != null)
                                {
                                    editor = instance.GetComponent <PropertyEditor>();
                                }
                            }
                        }
                    }
                    else
                    {
                        //if(input.type == ProceduralPropertyType.Enum)
                        //TODO: Implement enum from string array editor. //input.enumOptions

                        if (EditorsMap.IsPropertyEditorEnabled(propertyInfo.PropertyType))
                        {
                            GameObject editorPrefab = EditorsMap.GetPropertyEditor(propertyInfo.PropertyType);
                            GameObject instance     = Instantiate(editorPrefab);
                            instance.transform.SetParent(EditorsPanel, false);

                            if (instance != null)
                            {
                                editor = instance.GetComponent <PropertyEditor>();
                            }
                        }
                    }
                }
#endif

                if (editor == null)
                {
                    continue;
                }

                editor.Init(target, propertyInfo, descriptor.Label, null, descriptor.ValueChangedCallback, () =>
                {
                    RuntimeEditorApplication.SaveSelectedObjects();
                });
            }
        }
        private void Start()
        {
            GameObject          go               = RuntimeSelection.activeGameObject;
            ExposeToEditor      exposeToEditor   = go.GetComponent <ExposeToEditor>();
            HierarchyItem       hierarchyItem    = go.GetComponent <HierarchyItem>();
            HashSet <Component> ignoreComponents = new HashSet <Component>();

            if (exposeToEditor != null)
            {
                if (exposeToEditor.Colliders != null)
                {
                    for (int i = 0; i < exposeToEditor.Colliders.Length; ++i)
                    {
                        Collider collider = exposeToEditor.Colliders[i];
                        if (!ignoreComponents.Contains(collider))
                        {
                            ignoreComponents.Add(collider);
                        }
                    }
                }

                ignoreComponents.Add(exposeToEditor);
            }

            if (hierarchyItem != null)
            {
                ignoreComponents.Add(hierarchyItem);
            }

            InputName.text        = go.name;
            TogEnableDisable.isOn = go.activeSelf;

            InputName.onEndEdit.AddListener(OnEndEditName);
            TogEnableDisable.onValueChanged.AddListener(OnEnableDisable);
            Component[] components = go.GetComponents <Component>();
            for (int i = 0; i < components.Length; ++i)
            {
                Component component = components[i];
                if (component == null)
                {
                    continue;
                }

                if (ignoreComponents.Contains(component))
                {
                    continue;
                }

                if ((component.hideFlags & HideFlags.HideInInspector) != 0)
                {
                    continue;
                }

                if (EditorsMap.IsObjectEditorEnabled(component.GetType()))
                {
                    GameObject editorPrefab = EditorsMap.GetObjectEditor(component.GetType());
                    if (editorPrefab != null)
                    {
                        ComponentEditor componentEditorPrefab = editorPrefab.GetComponent <ComponentEditor>();
                        if (componentEditorPrefab != null)
                        {
                            ComponentEditor editor = Instantiate(componentEditorPrefab);
                            editor.EndEditCallback = () =>
                            {
                                RuntimeEditorApplication.SaveSelectedObjects();
                            };
                            editor.transform.SetParent(ComponentsPanel, false);
                            editor.Component = component;
                        }
                        else
                        {
                            Debug.LogErrorFormat("editor prefab {0} does not have ComponentEditor script", editorPrefab.name);
                        }
                    }
                }
            }
        }