virtual public void OnSelected() // look at a particular instance object { // get target myObject = target as GUIEditObject; // show elements myObject.ShowElements(); // show if ( GUIManager.GetInstance() ) { // if guiScreen then bring to front if ( myObject.guiScreen != null ) { if ( myObject.guiScreen.Parent == null ) UnityEngine.Debug.LogError("GUIEditObjectInspector.OnSelected() : guiScreen.Parent == null"); else myObject.guiScreen.Parent.SetScreenTo(myObject.guiScreen.name); } else GUIManager.GetInstance().SelectedGUIObject = myObject.guiObject; // attach this object to the GUIEditWigdet if available widget = GUIManager.GetInstance().gameObject.GetComponent<GUIEditWidget>(); if ( widget != null ) { widget.SetGUIObject(myObject.guiObject); } } }
public virtual GUIEditObject CopyObject( GUIEditObject parentEO, GUIObject guiObj, bool duplicate, bool clone=true ) { GameObject parent = parentEO.gameObject; GameObject newobj = new GameObject(guiObj.name); if ( newobj != null ) { GUIEditObject eo = newobj.AddComponent(typeof(GUIEditObject)) as GUIEditObject; // handle parenting newobj.transform.parent = parent.transform; newobj.transform.localPosition = Vector3.zero; // clone GUIObject at highest level, after that we have a duplicate of the whole guiobject // so we don't need to close on recursion if ( clone == true ) eo.guiObject = guiObj.Clone(); else eo.guiObject = guiObj; // duplicate the style (if any) if ( duplicate == true ) eo.guiObject.DuplicateStyle(); // do the rest eo.BaseName = guiObj.name; eo.name = guiObj.name; eo.Parent = parentEO;//parent.GetComponent<GUIEditObject>(); eo.Parent.AddChild(newobj); eo.ShowElements(); // add info to name newobj.name = "<" + eo.guiObject.ToString().Replace("GUI","") + ">" + newobj.name + " (copy)"; // if this object is a container then add elements GUIContainer container = eo.guiObject as GUIContainer; if ( container != null ) { foreach( GUIObject go in container.Elements ) CopyObject(eo,go,duplicate,false); } eo.OrderElements(); return eo; } return null; }
void ShowPasteOptions(GUIEditObject copyObj) { if ( showPasteOptions == true ) { Color save = GUI.color; GUI.color = Color.green; GUILayout.BeginHorizontal(); if ( GUILayout.Button ("Paste With Same Styles")) { DoPaste (copyObj,false); showPasteOptions = false; } if ( GUILayout.Button ("Paste With Unique Styles")) { DoPaste (copyObj,true); showPasteOptions = false; } GUILayout.EndHorizontal(); GUI.color = save; } }
void DoPaste( GUIEditObject copyObj, bool duplicate ) { // first copy GUIEditObject eo = CopyObject(myObject,copyObj.guiObject,duplicate); // set name eo.BaseName = copyObj.BaseName; // add this to this object's elements if ( myObject.guiScreen != null ) // parent is a screen myObject.guiScreen.Elements.Add(eo.guiObject); else { // parent is a normal container GUIContainer container = myObject.guiObject as GUIContainer; if ( container != null ) container.Elements.Add(eo.guiObject); } // let parent know new order eo.OrderElements(); // reorder ReorderContainer(); }
public void SetType( string guiName, GUIEditObject.GUITypes guiType ) { // create based on type if ( guiType == GUITypes.Screen ) { guiScreen = new GUIScreen(); guiScreen.name = guiName; } if ( guiType == GUITypes.Area ) { guiObject = new GUIArea(); guiObject.name = guiName; } if ( guiType == GUITypes.Label ) { guiObject = new GUILabel(); guiObject.name = guiName; } if ( guiType == GUITypes.Button ) { guiObject = new GUIButton(); guiObject.name = guiName; } if ( guiType == GUITypes.Horizontal ) { guiObject = new GUIHorizontalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Vertical ) { guiObject = new GUIVerticalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Scrollview ) { guiObject = new GUIScrollView(); guiObject.name = guiName; } if ( guiType == GUITypes.Toggle ) { guiObject = new GUIToggle(); guiObject.name = guiName; } if ( guiType == GUITypes.Space ) { guiObject = new GUISpace(); guiObject.name = guiName; } if ( guiType == GUITypes.EditBox ) { guiObject = new GUIEditbox(); guiObject.name = guiName; } if ( guiType == GUITypes.Box ) { guiObject = new GUIBox(); guiObject.name = guiName; } if ( guiType == GUITypes.HorizontalSlider ) { guiObject = new GUIHorizontalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.VerticalSlider ) { guiObject = new GUIVerticalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.Movie ) { guiObject = new GUIMovie(); guiObject.name = guiName; } }
public void Copy( GUIEditObject obj ) { // copy entire tree if ( obj.guiObject != null ) { guiObject = obj.guiObject.Clone(); } }
public void SetPasteObject( GUIEditObject paste ) { PasteObject = paste; }