Esempio n. 1
0
        public static void ColliderControlHelperGUI(Object[] objects)
        {
            SubColliderHelper[] _cols = objects.Where(r => r is SubColliderHelper).Cast <SubColliderHelper>().ToArray();

            bool bHasBC       = _cols.All(r => r.GetComponent <BoxCollider>() != null);
            bool isNotIsoTile = _cols.All(r => r.GetComponent <IsoTile>() == null);

            if (isNotIsoTile)
            {
                Util.CustomEditorGUI.NewParagraph("[Object Selector]");
                Util.CustomEditorGUI.ComSelector <IsoTile>(Selection.activeGameObject.GetComponentInParent <IsoTile>(), "GO IsoTile");
                var _iso2Ds = Selection.activeGameObject.GetComponentsInChildren <Iso2DObject>();
                foreach (var one in _iso2Ds)
                {
                    Util.CustomEditorGUI.ComSelector <Iso2DObject>(one, "GO Iso2D");
                }
                CustomEditorGUI.DrawSeperator();
            }

            if (bHasBC || isNotIsoTile)
            {
                NewParagraph("[Collider Control]");
                float fRayCastHeight = 10f * IsoMap.instance.gGrid.TileSize.y;
                if (bHasBC && GUILayout.Button(string.Format("Drop to the floor collider[Max({0:0.0})]", fRayCastHeight)))
                {
                    foreach (var _col in _cols)
                    {
                        if (_col.BC != null)
                        {
                            float fDropHeight = _col.BC.DropToFloor(_col.gameObject, fRayCastHeight);
                            if (fDropHeight > 0)
                            {
                                Debug.Log(string.Format("{0} fell {1} high.", _col.gameObject.name, fDropHeight));
                            }
                            else if (fDropHeight < 0)
                            {
                                Debug.Log(string.Format("{0} went up to {1} height because there is no floor within {2} range.",
                                                        _col.gameObject.name, -fDropHeight, fRayCastHeight));
                            }
                            else
                            {
                                Debug.Log(string.Format("There is no floor within {0} height.", fRayCastHeight));
                            }
                        }
                    }
                }
                if (isNotIsoTile && GUILayout.Button(string.Format("Change Parent to the nearest tile.", fRayCastHeight)))
                {
                    foreach (var _col in _cols)
                    {
                        _col.ReParent(0.5f);
                    }
                }
                if (isNotIsoTile && GUILayout.Button("Sync Light to Tile."))
                {
                    foreach (var _col in _cols)
                    {
                        var _tile = _col.GetComponentInParent <IsoTile>();
                        _tile.SyncIsoLight(_col.gameObject);
                    }
                }
                CustomEditorGUI.DrawSeperator();
            }

            if (isNotIsoTile && (bFoldout_ColliderControlGUI = !NewParagraphWithHideToggle("[Etc Control]", "Hide", !bFoldout_ColliderControlGUI)))
            {
                List <Iso2DObject> Iso2Ds = new List <Iso2DObject>();
                foreach (var _col in _cols)
                {
                    Iso2Ds.AddRange(_col.GetComponentsInChildren <Iso2DObject>());
                }
                if (Iso2Ds.Count > 0)
                {
                    Iso2Ds = Iso2Ds.Distinct().ToList();
                    GUILayoutOption heightLayout = GUILayout.Height(EditorGUIUtility.singleLineHeight * 3);
                    Iso2Ds.ForEach(r => Iso2DDrawer.Drawer(EditorGUILayout.GetControlRect(heightLayout), r.gameObject));
                }
            }
        }
 public static void Iso2DDrawField(SerializedProperty _Iso2D)
 {
     EditorGUI.PropertyField(Iso2DDrawer.GetRect(), _Iso2D);
 }