Ejemplo n.º 1
0
        //Set new component positions when one is adjusted
        public void SetComponentPositions(RuntimeEditor.Component source, float previousHeight, float newHeight)
        {
            int adjustedComponent = 0;                                     //Int for finding component adjusted

            for (int i = 0; i < inspectorReferences.components.Count; i++) //Iterate component list
            {
                if (inspectorReferences.components[i] == source)           //If this index matches adjusted component
                {
                    adjustedComponent = i;                                 //Set integer
                }
            }
            for (int i = 0; i < inspectorReferences.components.Count; i++)                                                               //Iterate component list
            {
                if (i > adjustedComponent)                                                                                               //If component is after the one that was adjusted
                {
                    RectTransform rect   = inspectorReferences.components[i].GetComponent <RectTransform>();                             //Get rect transform
                    Vector2       newPos = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y + (previousHeight - newHeight)); //Set position based on calculations of resizing of adjusted component
                    rect.anchoredPosition = newPos;                                                                                      //Set position to match calculations
                }
            }
            Vector2 newFooterPos = new Vector2(inspectorReferences.footer.anchoredPosition.x, inspectorReferences.footer.anchoredPosition.y + (previousHeight - newHeight)); //Calculate new footer position

            inspectorReferences.footer.anchoredPosition = newFooterPos;                                                                                                      //Set footer position
            contentHeight -= (previousHeight - newHeight);                                                                                                                   //Calculate final position
            inspectorReferences.contentWindow.sizeDelta = new Vector2(inspectorReferences.contentWindow.sizeDelta.x, contentHeight);                                         //Set content window size
        }
Ejemplo n.º 2
0
 void Awake()
 {
     globals = transform.root.GetComponent <Globals>();
     if (variableGeneratorSourceType == VariableGeneratorSourceType.Component)
     {
         rComponent  = GetComponent <RuntimeEditor.Component>();
         sourceFound = true;
     }
 }
Ejemplo n.º 3
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
        }