Ejemplo n.º 1
0
        /// <summary>
        /// Populates the editor with editing object's values.
        /// </summary>
        void PopulateObject()
        {
            if (editingObject == null)
            {
                return;
            }

            sidednessSwitch.toggle.isOn = !editingObject.singleSided;

            DestroyEditors();

            for (int i = 0; i < editingObject.callNumberRanges.Count; i++)
            {
                CallNumberRange       range  = editingObject.callNumberRanges[i];
                CallNumberRangeEditor editor = Instantiate(callNumberRangeEditorPrefab, transform);

                editor.onDelete = () => {
                    editingObject.callNumberRanges.Remove(range);
                    editor.Delete();
                };

                rangeEditors.Add(editor);
                editor.SetEditingObject(range);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new range to this object.
        /// </summary>
        public void AddCallNumberRange()
        {
            if (editingObject == null)
            {
                return;
            }

            CallNumberRange range = new CallNumberRange();

            editingObject.callNumberRanges.Add(range);
            CallNumberRangeEditor editor = Instantiate(callNumberRangeEditorPrefab, transform);

            rangeEditors.Add(editor);

            editor.onDelete = () => {
                editingObject.callNumberRanges.Remove(range);
                editor.Delete();
                ActionManager.shared.Push();
            };

            editor.Show(false, false);
            editor.Show(true, true);
            editor.SetEditingObject(range);

            ActionManager.shared.Push();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets up the script according to the given object. If we can edit it,
        /// then we update our values.
        /// </summary>
        /// <param name="obj">Object.</param>
        public void SetEditingObject(GameObject obj)
        {
            if (obj == null)
            {
                editingObject = null;
            }
            else
            {
                editingObject = obj.GetComponent <CallNumberRange>();
            }

            PopulateObject();
        }
Ejemplo n.º 4
0
        public void FromJSON(FloorController api, JSONNode root)
        {
            Rectangle r = GetComponent <Rectangle>();

            r.SetCenter(new Vector2(root["center_x"].AsFloat, root["center_y"].AsFloat));
            r.SetSize(new Vector2(root["width"].AsFloat, root["height"].AsFloat));
            r.SetRotation(root["rotation"].AsFloat);
            singleSided      = root["is_double_sided"].AsInt == 0;
            callNumberRanges = new List <CallNumberRange>();

            foreach (JSONNode node in root["call_ranges"].AsArray)
            {
                CallNumberRange range = new CallNumberRange();
                range.FromJSON(api, node);
                callNumberRanges.Add(range);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets up the script according to the given editable object.
 /// </summary>
 /// <param name="obj">Object.</param>
 public void SetEditingObject(CallNumberRange obj)
 {
     editingObject = obj;
     PopulateObject();
 }