Esempio n. 1
0
 /// <summary>Modifies the Parent of the Element while adjusting the Children of the previous and new parent Elements</summary>
 public void SetParent(CGElement p)
 {
     try{
         if (IsAboveInHierarchy(p))
         {
             p.GetParent().GetChildren().Remove(p);
             p.SetParentRaw(parent);
             parent.GetChildren().Add(p);
             SetParent(p);
         }
         else
         {
             p.GetChildren().Add(this);
             if (parent != null)
             {
                 parent.GetChildren().Remove(this);
             }
             parent = p;
                             #if UNITY_EDITOR
             foldout = true;
                             #endif
         }
     }catch (System.Exception e) {
         Debug.LogWarning("CreateGUI - \"" + name + "\" could not set parent \"" + p.name + "\" \n" + e.Message);
     }
 }
Esempio n. 2
0
 public CGElement AddElement(string baseName,CGElement parent)
 {
     CGElement element = ScriptableObject.CreateInstance(selectedElementType) as CGElement;
     Undo.RegisterCreatedObjectUndo(element,"CreateGUI Add Element");
     element.name = baseName;
     element.SetParentRaw(parent);
     parent.GetChildren().Add(element);
     return element;
 }
Esempio n. 3
0
    public CGElement AddElement(string baseName, CGElement parent)
    {
        CGElement element = ScriptableObject.CreateInstance(selectedElementType) as CGElement;

        Undo.RegisterCreatedObjectUndo(element, "CreateGUI Add Element");
        element.name = baseName;
        element.SetParentRaw(parent);
        parent.GetChildren().Add(element);
        return(element);
    }
Esempio n. 4
0
 CGElement SearchElements(CGElement element, string Name)
 {
     foreach (CGElement child in element.GetChildren())
     {
         if (child.name == Name)
         {
             return(child);
         }
         else
         {
             CGElement result = SearchElements(child, Name);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
Esempio n. 5
0
    List <CGElement> SaveRecursively(List <CGElement> children, string save)
    {
        List <CGElement> copies = new List <CGElement>();

        foreach (CGElement child in children)
        {
            if (child != null)
            {
                CGElement copy = (CGElement)Instantiate(child);
                copy.name = child.name;
                copies.Add(copy);
                if (save != "")
                {
                    AssetDatabase.AddObjectToAsset(copy, save);
                }
                copy.SetChildren(SaveRecursively(copy.GetChildren(), save));
            }
        }
        return(copies);
    }
Esempio n. 6
0
    /// <summary>Modifies the Parent of the Element while adjusting the Children of the previous and new parent Elements</summary>
    public void SetParent(CGElement p)
    {
        try{
            if(IsAboveInHierarchy(p)){

                p.GetParent().GetChildren().Remove(p);
                p.SetParentRaw(parent);
                parent.GetChildren().Add(p);
                SetParent(p);
            }else{
                p.GetChildren().Add(this);
                if(parent != null) parent.GetChildren().Remove(this);
                parent = p;
                #if UNITY_EDITOR
                foldout = true;
                #endif
            }
        }catch(System.Exception e){
            Debug.LogWarning("CreateGUI - \""+name+"\" could not set parent \""+p.name+"\" \n"+e.Message);
        }
    }
Esempio n. 7
0
    CGElement SearchElements(CGElement element,string Name)
    {
        foreach(CGElement child in element.GetChildren()){

            if(child.name == Name) return child;
            else{
                CGElement result = SearchElements(child,Name);
                if(result != null) return result;
            }
        }
        return null;
    }