Exemplo n.º 1
0
        public static void LoadContainerData(this ProceduralObjectsLogic logic, ProceduralObjectContainer[] containerArray)
        {
            logic.proceduralObjects = new List <ProceduralObject>();
            if (logic.availableProceduralInfos == null)
            {
                logic.availableProceduralInfos = CreateProceduralInfosList();
            }
            if (logic.availableProceduralInfos.Count < 0)
            {
                logic.availableProceduralInfos = CreateProceduralInfosList();
            }

            foreach (var c in containerArray)
            {
                try
                {
                    var obj = new ProceduralObject(c, logic.basicTextures, logic.layerManager);
                    if (obj.RequiresUVRecalculation && !obj.disableRecalculation)
                    {
                        obj.m_mesh.uv = Vertex.RecalculateUVMap(obj, Vertex.CreateVertexList(obj));
                    }
                    if (!obj.isPloppableAsphalt)
                    {
                        obj.m_mesh.RecalculateNormals(60);
                        obj.m_mesh.RecalculateBounds();
                    }
                    logic.proceduralObjects.Add(obj);
                }
                catch (Exception e)
                {
                    Debug.LogError("[ProceduralObjects] Failed to load a Procedural Object : \n" + e.GetType().ToString() + " : " + e.Message + "\n" + e.StackTrace);
                }
            }
        }
Exemplo n.º 2
0
        private void drawCharTable(int id)
        {
            GUI.DragWindow(new Rect(0, 0, 388, 28));
            GUI.Label(new Rect(7, 30, 385, 26), string.Format(LocalizationManager.instance.current["font_chars_available"], selectedCharTable.m_fontName));
            var height = (Mathf.FloorToInt(selectedCharTable.m_orderedChars.Length / 10) + 1) * 67 + (ProceduralObjectsMod.ShowDeveloperTools.value ? 52 : 6);

            scrollCharTable          = GUI.BeginScrollView(new Rect(5, 57, 416, 338), scrollCharTable, new Rect(0, 0, 400, height));
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            for (int i = 0; i < selectedCharTable.m_orderedChars.Length; i++)
            {
                int line       = Mathf.FloorToInt(i / 10);
                int leftOffset = i % 10;
                GUI.Box(new Rect(7 + leftOffset * 39, 3 + 67 * line, 35, 62), string.Empty);
                GUI.Label(new Rect(7 + leftOffset * 39, 2 + 67 * line, 35, 28), "<size=20>" + selectedCharTable.m_orderedChars[i] + "</size>");
                GUI.Label(new Rect(7 + leftOffset * 39, 30 + 67 * line, 35, 35), selectedCharTable.m_charTexturesNormal[selectedCharTable.m_orderedChars[i]]);
            }
            GUI.skin.label.alignment = TextAnchor.UpperLeft;
            if (ProceduralObjectsMod.ShowDeveloperTools.value)
            {
                GUI.Label(new Rect(210, height - 45, 176, 20), "Excluded characters indexes");
                excludedChars = GUI.TextField(new Rect(210, height - 25, 176, 24), excludedChars);
                if (GUI.Button(new Rect(7, height - 45, 200, 44), "Calculate & Export Kerning data"))
                {
                    selectedCharTable.ExportKerning(excludedChars);
                }
            }
            GUI.EndScrollView();
            if (GUI.Button(new Rect(391, 3, 28, 28), "X"))
            {
                ProceduralObjectsLogic.PlaySound();
                CloseCharTable();
            }
        }
 public POStatisticsManager(ProceduralObjectsLogic logic)
 {
     instance   = this;
     this.logic = logic;
     RefreshCounters();
     window = new Rect(555, 200, 300, 235);
 }
Exemplo n.º 4
0
 void draw(int id)
 {
     GUI.DragWindow(new Rect(0, 0, 287, 28));
     if (GUI.Button(new Rect(289, 4, 28, 27), "X"))
     {
         ProceduralObjectsLogic.PlaySound();
         showWindow = false;
     }
     GUI.Label(new Rect(5, 22, 310, 28), LocalizationManager.instance.current["layers_desc"]);
     GUI.Box(new Rect(10, 50, 300, 295), string.Empty);
     scrollLayers = GUI.BeginScrollView(new Rect(7, 52, 306, 291), scrollLayers, new Rect(0, 0, 282, m_layers.Count * 26 + 32));
     for (int i = 0; i < m_layers.Count; i++)
     {
         if (GUI.Button(new Rect(9, i * 26 + 1, 24, 24), ProceduralObjectsMod.Icons[m_layers[i].m_isHidden ? 3 : 4]))
         {
             ProceduralObjectsLogic.PlaySound();
             m_layers[i].m_isHidden = !m_layers[i].m_isHidden;
         }
         m_layers[i].m_name = GUI.TextField(new Rect(35, i * 26 + 1, 219, 24), m_layers[i].m_name);
         GUI.color          = Color.red;
         if (GUI.Button(new Rect(256, i * 26 + 1, 24, 24), "X"))
         {
             ProceduralObjectsLogic.PlaySound();
             RemoveLayer(m_layers[i], logic.proceduralObjects);
         }
         GUI.color = Color.white;
     }
     newLayerText = GUI.TextField(new Rect(35, m_layers.Count * 26 + 1, 219, 24), newLayerText);
     if (GUI.Button(new Rect(256, m_layers.Count * 26 + 1, 24, 24), "<size=14>+</size>"))
     {
         ProceduralObjectsLogic.PlaySound();
         AddLayer(newLayerText);
     }
     GUI.EndScrollView();
 }
        private static void drawButton(Vector2 position, SMActionPrefab smprefab)
        {
            if (GUI.Button(new Rect(position, new Vector2(180, 22)), string.Empty))
            {
                ProceduralObjectsLogic.PlaySound();
                var action = (SelectionModeAction)Activator.CreateInstance(smprefab.type);
                action.logic = ProceduralObjectsLogic.instance;
                ProceduralObjectsLogic.instance.selectionModeAction = action;
                action.OnOpen(new List <ProceduralObject>(ProceduralObjectsLogic.instance.pObjSelection));
            }
            var align = GUI.skin.label.alignment;

            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            GUI.Label(new Rect(position + new Vector2(3, 0), new Vector2(178, 22)), LocalizationManager.instance.current[smprefab.id]);
            if (smprefab.keyBinding != null)
            {
                if (!smprefab.keyBinding.IsEmpty())
                {
                    GUI.skin.label.alignment = TextAnchor.MiddleRight;
                    GUI.color = Color.gray;
                    GUI.Label(new Rect(position + new Vector2(1, 1), new Vector2(174, 20)), "<size=10><i>" + smprefab.keyBinding.m_fullKeys + "</i></size> ");
                    GUI.color = Color.white;
                }
            }
            GUI.skin.label.alignment = align;
        }
Exemplo n.º 6
0
        public void Remove(ProceduralObjectsLogic logic, ProceduralObject po)
        {
            if (!objects.Contains(po))
            {
                return;
            }

            po.group         = null;
            po.isRootOfGroup = false;
            if (objects.Count == 1)
            {
                logic.groups.Remove(this);
                if (logic.selectedGroup == this)
                {
                    logic.selectedGroup = null;
                }
                return;
            }
            if (objects.Contains(po))
            {
                objects.Remove(po);
            }
            if (root == po)
            {
                ChooseFirstAsRoot();
            }
        }
        public static ProceduralObjectContainer[] GetContainerList(this ProceduralObjectsLogic logic)
        {
            var list = new List <ProceduralObjectContainer>();

            if (logic.proceduralObjects == null)
            {
                return(null);
            }
            foreach (ProceduralObject obj in logic.proceduralObjects)
            {
                list.Add(new ProceduralObjectContainer(obj));
            }
            try
            {
                if (PopupStart.loading_failures.Count > 0)
                {
                    foreach (var f in PopupStart.loading_failures)
                    {
                        if (!f.keep)
                        {
                            continue;
                        }
                        for (int i = 0; i < f.containers.Count; i++)
                        {
                            list.Add(f.containers.Keys.ToList()[i]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[ProceduralObjects] Error implementing the POs that failed to load back into saving\n" + e.ToString());
            }
            return(list.ToArray());
        }
Exemplo n.º 8
0
        public static POGroup MakeGroup(ProceduralObjectsLogic logic, List <ProceduralObject> objects, ProceduralObject root)
        {
            var group = (root.group == null) ? CreateGroupWithRoot(root) : root.group;

            foreach (var obj in objects)
            {
                if (obj.isRootOfGroup && obj.group != null)
                {
                    if (logic.groups.Contains(obj.group))
                    {
                        logic.groups.Remove(obj.group);
                    }
                    foreach (var pObj in obj.group.objects)
                    {
                        pObj.group         = group;
                        pObj.isRootOfGroup = false;
                        group.AddToGroup(pObj);
                    }
                }
                else
                {
                    obj.group         = group;
                    obj.isRootOfGroup = false;
                    group.AddToGroup(obj);
                }
            }
            group.root = root;
            group.root.isRootOfGroup = true;
            logic.groups.Add(group);
            return(group);
        }
Exemplo n.º 9
0
            public FloatInputField DrawField(Rect rect, float value, bool allowNegatives, float sliderMin, float sliderMax, bool showMaxButton, float maxValue)
            {
                var str = GUI.TextField(new Rect(rect.x, rect.y, rect.width - 40, rect.height - 14), inputString);

                if (returnValue != value)
                {
                    returnValue = value;
                    inputString = value.ToString();
                }
                else
                {
                    SetString(str, allowNegatives);
                }

                var clampedReturn = Mathf.Clamp(returnValue, sliderMin, sliderMax);
                var slider        = GUI.HorizontalSlider(new Rect(rect.x, rect.yMax - 12, rect.width - 40, 12), clampedReturn, sliderMin, sliderMax);

                if (slider != clampedReturn)
                {
                    returnValue = Mathf.Round(slider);
                    inputString = returnValue.ToString();
                }
                if (showMaxButton)
                {
                    if (GUI.Button(new Rect(rect.xMax - 38, rect.y, 38, rect.height - 14), LocalizationManager.instance.current["max_reached"]))
                    {
                        ProceduralObjectsLogic.PlaySound();
                        returnValue = Mathf.Round(maxValue);
                        inputString = returnValue.ToString();
                    }
                }
                return(this);
            }
Exemplo n.º 10
0
        public override void OnActionGUI(Vector2 uiPos)
        {
            if (grabbablePoints == null)
            {
                return;
            }
            grabbablePoints.OnGUI(refCenter, refRot);

            var rect = CollisionUI(uiPos);

            if (!ProceduralObjectsMod.UseUINightMode.value)
            {
                GUI.DrawTexture(rect, GUIUtils.bckgTex, ScaleMode.StretchToFill);
            }
            GUI.Box(rect, string.Empty);
            GUI.Label(new Rect(uiPos + new Vector2(2, 2), new Vector2(246, 79)), grabbablePoints.kbSmooth.m_fullKeys + " : " + LocalizationManager.instance.current["hold_for_smooth"] + "\n" + grabbablePoints.kbSlow.m_fullKeys + " : " + LocalizationManager.instance.current["hold_slow_together"]
                      + "\n" + KeyBindingsManager.instance.GetBindingFromName("scale_scaleUp").m_fullKeys + "/" + KeyBindingsManager.instance.GetBindingFromName("scale_scaleDown").m_fullKeys + " : " + LocalizationManager.instance.current["KB_scaleUp"] + "/" + LocalizationManager.instance.current["KB_scaleDown"]);

            if (GUI.Button(new Rect(uiPos.x + 76, uiPos.y + 82, 64, 22), LocalizationManager.instance.current["ok"]))
            {
                ProceduralObjectsLogic.PlaySound();
                confirmedDone = true;
                ExitAction();
                return;
            }
            if (GUI.Button(new Rect(uiPos.x + 143, uiPos.y + 82, 108, 22), LocalizationManager.instance.current["cancel"]))
            {
                ProceduralObjectsLogic.PlaySound();
                ExitAction();
                return;
            }
        }
Exemplo n.º 11
0
        void draw(int id)
        {
            GUI.DragWindow(new Rect(0, 0, 268, 28));
            if (GUIUtils.CloseHelpButtons(winRect, "Layers"))
            {
                showWindow      = false;
                expandingWindow = false;
            }
            GUI.Label(new Rect(5, 22, 310, 28), LocalizationManager.instance.current["layers_desc"]);
            GUIUtils.DrawSeparator(new Vector2(7, 46), 306);
            scrollLayers = GUI.BeginScrollView(new Rect(7, 52, 306, winRect.height - 69), scrollLayers, new Rect(0, 0, 282, m_layers.Count * 26 + 32));
            for (int i = 0; i < m_layers.Count; i++)
            {
                if (GUI.Button(new Rect(9, i * 26 + 1, 24, 24), ProceduralObjectsMod.Icons[m_layers[i].m_isHidden ? 3 : 4]))
                {
                    ProceduralObjectsLogic.PlaySound();
                    m_layers[i].m_isHidden = !m_layers[i].m_isHidden;
                }
                bool canBeMoved = CanLayerMoveUp(m_layers[i]) || CanLayerMoveDown(m_layers[i]);
                if (canBeMoved)
                {
                    if (CanLayerMoveUp(m_layers[i]))
                    {
                        if (GUI.Button(new Rect(35, i * 26 + 1, 25, 12), ProceduralObjectsMod.Icons[6]))
                        {
                            ProceduralObjectsLogic.PlaySound();
                            MoveLayerUp(m_layers[i]);
                        }
                    }
                    if (CanLayerMoveDown(m_layers[i]))
                    {
                        if (GUI.Button(new Rect(35, i * 26 + 13.5f, 25, 12), ProceduralObjectsMod.Icons[7]))
                        {
                            ProceduralObjectsLogic.PlaySound();
                            MoveLayerDown(m_layers[i]);
                        }
                    }
                }
                m_layers[i].m_name = GUI.TextField(new Rect(canBeMoved ? 62 : 35, i * 26 + 1, canBeMoved ? 192 : 219, 24), m_layers[i].m_name);
                GUI.color          = Color.red;
                if (GUI.Button(new Rect(256, i * 26 + 1, 24, 24), "X"))
                {
                    ProceduralObjectsLogic.PlaySound();
                    RemoveLayer(m_layers[i], logic.proceduralObjects);
                }
                GUI.color = Color.white;
            }
            newLayerText = GUI.TextField(new Rect(35, m_layers.Count * 26 + 1, 219, 24), newLayerText);
            if (GUI.Button(new Rect(256, m_layers.Count * 26 + 1, 24, 24), "<size=14>+</size>"))
            {
                ProceduralObjectsLogic.PlaySound();
                AddLayer(newLayerText);
            }
            GUI.EndScrollView();

            if (GUI.RepeatButton(new Rect(120, winRect.height - 14, 80, 10), string.Empty))
            {
                expandingWindow = true;
            }
        }
Exemplo n.º 12
0
 public MeasurementsManager(ProceduralObjectsLogic logic)
 {
     this.logic  = logic;
     instance    = this;
     measureMode = 0;
     window      = new Rect(555, 200, 350, 280);
 }
        public static void DrawToolsControls(Rect rect, bool isGeneral)
        {
            GUI.BeginGroup(rect);
            // w 380
            if (GUI.Button(new Rect(0, 0, 22, 22), ProceduralObjectsMod.ShowToolsControls.value ? "▼" : "►"))
            {
                ProceduralObjectsLogic.PlaySound();
                scrollControls = Vector2.zero;
                ProceduralObjectsMod.ShowToolsControls.value = !ProceduralObjectsMod.ShowToolsControls.value;
            }

            GUI.Label(new Rect(24, 1, rect.width - 28, 20), "<b>" + LocalizationManager.instance.current["controls"] + ":</b>");
            if (ProceduralObjectsMod.ShowToolsControls.value)
            {
                var height = GUI.skin.label.CalcHeight(new GUIContent(isGeneral ? GTControls : CTControls), 358);

                GUI.Box(new Rect(0, 25, rect.width - 22, rect.height - 30), string.Empty);
                scrollControls = GUI.BeginScrollView(new Rect(2, 27, rect.width - 1, rect.height - 32), scrollControls, new Rect(0, 0, 358, height + 2));
                GUI.Label(new Rect(2, 0, 358, height), isGeneral ? GTControls : CTControls);
                GUI.EndScrollView();

                GUIUtils.DrawSeparator(new Vector2(0, rect.height - 1), rect.width);
            }
            else
            {
                GUIUtils.DrawSeparator(new Vector2(0, 25), rect.width);
            }

            GUI.EndGroup();
        }
Exemplo n.º 14
0
        public override void OnSaveData()
        {
            base.OnSaveData();
            Debug.Log("[ProceduralObjects] Data saving started.");
            MemoryStream proceduralObjStream = new MemoryStream(), layerStream = new MemoryStream();

            if (ProceduralObjectsMod.gameLogicObject == null)
            {
                return;
            }
            ProceduralObjectsLogic logic = ProceduralObjectsMod.gameLogicObject.GetComponent <ProceduralObjectsLogic>();

            if (logic == null)
            {
                return;
            }
            BinaryFormatter bFormatter = new BinaryFormatter();

            ProceduralObjectContainer[] dataContainer = logic.GetContainerList();
            Layer[] layerContainer = logic.layerManager.m_layers.ToArray();
            try
            {
                if (dataContainer != null)
                {
                    bFormatter.Serialize(proceduralObjStream, dataContainer);
                    var splittedDict = SplitArray(proceduralObjStream.ToArray());
                    foreach (string key in serializableDataManager.EnumerateData())
                    {
                        if (key.Contains(dataKey) && !splittedDict.ContainsKey(key))
                        {
                            serializableDataManager.EraseData(key);
                            Debug.Log("[ProceduralObjects] Erased data array " + key + " because it wasn't used anymore");
                        }
                    }
                    Debug.Log("[ProceduralObjects] Data saving : saving " + splittedDict.Count.ToString() + " splited data array(s).");
                    foreach (KeyValuePair <string, byte[]> kvp in splittedDict)
                    {
                        serializableDataManager.SaveData(kvp.Key, kvp.Value);
                    }
                    Debug.Log("[ProceduralObjects] Data was serialized and saved. Saved " + dataContainer.Count() + " procedural objects.");
                }
                if (layerContainer != null)
                {
                    bFormatter.Serialize(layerStream, layerContainer);
                    serializableDataManager.SaveData(layerKey, layerStream.ToArray());
                }
                // logic.Refresh();
            }
            catch (Exception e)
            {
                Debug.LogError("[ProceduralObjects] Data failed to save completely due to " + e.GetType().ToString() + " : \"" + e.Message + "\"");
            }
            finally
            {
                proceduralObjStream.Close();
                layerStream.Close();
                Debug.Log("[ProceduralObjects] Data saving ended.");
            }
        }
 public virtual void OnActionGUI(Vector2 uiPos)
 {
     if (GUI.Button(new Rect(uiPos, new Vector2(130, 22)), LocalizationManager.instance.current["cancel"]))
     {
         ProceduralObjectsLogic.PlaySound();
         ExitAction();
     }
 }
Exemplo n.º 16
0
 public void DrawButton(Rect rect)
 {
     if (GUI.Button(rect, new GUIContent(Icon, "[POSM]" + LocalizationId)))
     {
         ProceduralObjectsLogic.PlaySound();
         onClick.Invoke();
     }
 }
Exemplo n.º 17
0
 public static void HelpButton(Rect position, string wikiHelpPage)
 {
     if (GUI.Button(new Rect(position.x, position.y, 24, 24), buttons[1], GUI.skin.label))
     {
         ProceduralObjectsLogic.PlaySound();
         ProceduralObjectsMod.OpenURL(LocalizationManager.instance.current.LocalizedWikiLink(ProceduralObjectsMod.DOCUMENTATION_URL + wikiHelpPage));
     }
 }
Exemplo n.º 18
0
        private void draw(int id)
        {
            GUI.DragWindow(new Rect(0, 0, 298, 21));
            if (GUIUtils.CloseHelpButtons(window, "Measurements"))
            {
                CloseWindow(); return;
            }
            GUI.Label(new Rect(5, 21, 340, 21), LocalizationManager.instance.current["measurmt_desc"]);

            if (GUI.Button(new Rect(5, 42, 167, 24), LocalizationManager.instance.current["measurmt_dist"]))
            {
                ProceduralObjectsLogic.PlaySound();
                UnityEngine.Object.Destroy(lineRenderer);
                UnityEngine.Object.Destroy(gameObject);
                measureMode = 1;
                Result      = -1f;
                pos0        = Vector3.down;
                pos1        = Vector3.down;
                pos2        = Vector3.down;
            }
            if (GUI.Button(new Rect(178, 42, 167, 24), LocalizationManager.instance.current["measurmt_ang"]))
            {
                ProceduralObjectsLogic.PlaySound();
                UnityEngine.Object.Destroy(lineRenderer);
                UnityEngine.Object.Destroy(gameObject);
                measureMode = 2;
                Result      = -1f;
                pos0        = Vector3.down;
                pos1        = Vector3.down;
                pos2        = Vector3.down;
            }
            bool anythingSelectable = AnythingSelectable();

            switch (measureMode)
            {
            case 1:
                GUI.DrawTexture(new Rect(25, 70, 300, 20), ProceduralObjectsMod.Icons[13]);
                SelectAsPoint(new Rect(4, 90, 120, 20), 0, anythingSelectable);
                SelectAsPoint(new Rect(226, 90, 120, 20), 1, anythingSelectable);
                if (Result != -1f)
                {
                    GUI.Label(new Rect(5, 114, 200, 23), "<size=14>" + Gizmos.ConvertToDistanceUnit(Result).ToString("n2") + ProceduralObjectsMod.distanceUnit + "</size>");
                }
                break;

            case 2:
                GUI.DrawTexture(new Rect(25, 70, 300, 150), ProceduralObjectsMod.Icons[14]);
                SelectAsPoint(new Rect(4, 90, 120, 20), 0, anythingSelectable);
                SelectAsPoint(new Rect(105, 218, 120, 20), 2, anythingSelectable);
                SelectAsPoint(new Rect(226, 90, 120, 20), 1, anythingSelectable);
                if (Result != -1f)
                {
                    GUI.Label(new Rect(5, 240, 200, 23), "<size=14>" + (Result * (ProceduralObjectsMod.AngleUnits.value == 1 ? Mathf.Deg2Rad : 1f)).ToString("n2") + ProceduralObjectsMod.angleUnit + "</size>");
                }
                break;
            }
        }
 public bool DrawPicker(Rect rect)
 {
     if (GUI.Button(rect, ProceduralObjectsMod.Icons[12]))
     {
         ProceduralObjectsLogic.PlaySound();
         return(true);
     }
     return(false);
 }
Exemplo n.º 20
0
 public static bool CloseButton(Rect window)
 {
     if (GUI.Button(new Rect(window.width - 25, 2, 24, 24), buttons[0], GUI.skin.label))
     {
         ProceduralObjectsLogic.PlaySound();
         return(true);
     }
     return(false);
 }
Exemplo n.º 21
0
 public static bool CloseHelpButtonsURL(Rect window, string url)
 {
     if (GUI.Button(new Rect(window.width - 51, 2, 24, 24), buttons[1], GUI.skin.label))
     {
         ProceduralObjectsLogic.PlaySound();
         ProceduralObjectsMod.OpenURL(url);
     }
     return(CloseButton(window));
 }
 public ModuleManager(ProceduralObjectsLogic logic)
 {
     modules         = new List <POModule>();
     enabledModules  = new List <POModule>();
     openedUIModules = new List <POModule>();
     searchResults   = new Dictionary <POModuleType, int>();
     searchTextfield = "";
     instance        = this;
     this.logic      = logic;
 }
Exemplo n.º 23
0
 public static void DeleteGroup(ProceduralObjectsLogic logic, POGroup group)
 {
     foreach (ProceduralObject obj in group.objects)
     {
         logic.moduleManager.DeleteAllModules(obj);
         logic.activeIds.Remove(obj.id);
         logic.proceduralObjects.Remove(obj);
     }
     logic.groups.Remove(group);
 }
Exemplo n.º 24
0
        private void SetColor(Color color)
        {
            ProceduralObjectsLogic.PlaySound();
            float h, s, v;

            Color.RGBToHSV(color, out h, out s, out v);
            this.H = h;
            this.GenerateSVPicker();
            this.S = s;
            this.V = v;
            onColorChanged.Invoke(Color.HSVToRGB(this.H, this.S, this.V));
        }
Exemplo n.º 25
0
        public static GUIPainter DrawPainter(GUIPainter painter, Vector2 samplePosition, Vector2 pickerPosition, Color color, Action <Color> onColorChanged, Action onSampleClick)
        {
            if (painter == null)
            {
                painter = new GUIPainter()
                {
                    showPicker     = false,
                    samplePosition = samplePosition,
                    pickerPosition = pickerPosition,
                    clickingH      = false,
                    clickingSV     = false,
                    onColorChanged = onColorChanged
                };
                float h, s, v;
                Color.RGBToHSV(color, out h, out s, out v);
                painter.H = h;
                painter.S = s;
                painter.V = v;
                painter.GenerateSVPicker();
            }

            /* float nh, ns, nv;
             * Color.RGBToHSV(color, out nh, out ns, out nv);
             * painter.H = nh;
             * painter.S = ns;
             * painter.V = nv; */
            // painter.onColorChanged = onColorChanged;
            GUI.color = new Color(color.r, color.g, color.b);
            if (GUI.Button(new Rect(samplePosition, new Vector2(26, 20)), "████"))
            {
                ProceduralObjectsLogic.PlaySound();
                if (painter.showPicker == false)
                {
                    float nh, ns, nv;
                    Color.RGBToHSV(color, out nh, out ns, out nv);
                    painter.H = nh;
                    painter.S = ns;
                    painter.V = nv;
                    painter.GenerateSVPicker();
                }
                painter.showPicker = !painter.showPicker;
                onSampleClick.Invoke();
            }
            GUI.color = Color.white;
            if (painter.showPicker)
            {
                DrawPicker(painter, color);
            }
            painter.samplePosition = samplePosition;
            painter.pickerPosition = pickerPosition;
            return(painter);
        }
Exemplo n.º 26
0
        public static List <ProceduralObject> ExplodeGroup(ProceduralObjectsLogic logic, POGroup group)
        {
            var list = new List <ProceduralObject>();

            foreach (var obj in group.objects)
            {
                list.Add(obj);
                obj.group         = null;
                obj.isRootOfGroup = false;
            }
            logic.groups.Remove(group);
            return(list);
        }
Exemplo n.º 27
0
        public static int GetNextUnusedId(this List <ProceduralObject> list)
        {
            ProceduralObjectsLogic logic = ProceduralObjectsMod.gameLogicObject.GetComponent <ProceduralObjectsLogic>();

            for (int i = 0; true; i++)
            {
                if (!logic.activeIds.Contains(i))
                {
                    logic.activeIds.Add(i);
                    return(i);
                }
            }
        }
Exemplo n.º 28
0
 public override void OnActionGUI(Vector2 uiPos)
 {
     if (GUI.Button(new Rect(uiPos, new Vector2(180, 22)), LocalizationManager.instance.current["snapToGround"]))
     {
         ProceduralObjectsLogic.PlaySound();
         Snap();
         ExitAction();
     }
     if (GUI.Button(new Rect(uiPos.x, uiPos.y + 23, 180, 22), LocalizationManager.instance.current["cancel"]))
     {
         ProceduralObjectsLogic.PlaySound();
         ExitAction();
     }
 }
Exemplo n.º 29
0
        /*
         * public static void MakeMeshUnique(this ProceduralObject obj)
         * {
         *  obj.meshStatus = 2;
         *  obj.m_mesh = obj.m_mesh.InstantiateMesh();
         *  obj.allVertices = obj.m_mesh.vertices;
         * //  obj.m_mesh.SetVertices(new List<Vector3>(obj.allVertices));
         * } */
        public static ProceduralObjectContainer[] GetContainerList(this ProceduralObjectsLogic logic)
        {
            var list = new List <ProceduralObjectContainer>();

            if (logic.proceduralObjects == null)
            {
                return(null);
            }
            foreach (ProceduralObject obj in logic.proceduralObjects)
            {
                list.Add(new ProceduralObjectContainer(obj));
            }
            return(list.ToArray());
        }
Exemplo n.º 30
0
 void DrawDirButton(Vector2 pos, string text, Vector3 dir)
 {
     if (dir == projectionDirection)
     {
         GUI.color = Color.red;
     }
     if (GUI.Button(new Rect(pos, new Vector2(42, 20)), text))
     {
         ProceduralObjectsLogic.PlaySound();
         projectionDirection = dir;
         UpdateArrowDirection(projectionDirection);
     }
     GUI.color = Color.white;
 }