Ejemplo n.º 1
0
        //Generate a component
        void GenerateComponent(UnityEngine.Component component)
        {
            inspectorReferences.components.Clear();                                                                             //Clear current component references
            GameObject go     = Instantiate(componentPrefab as GameObject, inspectorReferences.contentWindow.transform, false); //Instantiate component element
            string     cName  = component.GetType().ToString();                                                                 //Get Component name from type
            string     nSpace = component.GetType().Namespace;                                                                  //Get Component namespace

            if (nSpace != null)
            {
                cName = cName.Replace(nSpace, "").Replace(".", "");                             //Remove namespace from name
            }
            go.name = cName;                                                                    //Set object name
            RectTransform cRect = go.GetComponent <RectTransform>();                            //Get rect transform

            cRect.anchoredPosition = new Vector2(0, -contentHeight);                            //Set component position to calculated position
            RuntimeEditor.Component newComponent = go.GetComponent <RuntimeEditor.Component>(); //Get Component.cs reference
            generatedComponents.Add(newComponent);                                              //Add to list of component scripts
            newComponent.SetupComponent(this, component);                                       //Start setup of component script
            inspectorReferences.components.Add(newComponent);                                   //Add to component script list on Inspector.cs
            //contentHeight += cRect.sizeDelta.y; //Calculate position for next Inspector item
        }