Ejemplo n.º 1
0
        public void CollectMyBounds()
        {
            var wbso = WorldBoundsSettings.Single;

            if (!wbso)
            {
                return;
            }

            if (WorldBoundsSettings.Single.worldBoundsGroups.Count == 0)
            {
                WorldBoundsSettings.Single.worldBoundsGroups.Add(new WorldBoundsGroup());
            }

            // If this is no longer a existing worldbounds layer, reset to default
            if (worldBoundsGrp >= WorldBoundsSettings.Single.worldBoundsGroups.Count)
            {
                worldBoundsGrp = 0;
            }

            var grp = wbso.worldBoundsGroups[worldBoundsGrp];

            if (factorIn == BoundsTools.BoundsType.Manual)
            {
                myBounds      = manualBounds;
                myBoundsCount = 1;
            }
            else
            {
                myBounds = BoundsTools.CollectMyBounds(gameObject, factorIn, out myBoundsCount, includeChildren, false);
            }

            // Remove this from all Groups then readd to the one it currently belongs to.
            WorldBoundsSettings.RemoveWorldBoundsFromAll(this);

            if (myBoundsCount > 0 && enabled)
            {
                if (!grp.activeWorldBounds.Contains(this))
                {
                    grp.activeWorldBounds.Add(this);
                    grp.RecalculateWorldCombinedBounds();
                }
            }

            if (OnWorldBoundsChange != null)
            {
                OnWorldBoundsChange();
            }
        }
Ejemplo n.º 2
0
        //static GUIContent gngc = new GUIContent("", "(Editor only name), used in selection popup lists to identify each group.");

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            bool haschanged = false;

            float lw = EditorGUIUtility.labelWidth;

            Rect r = position;

            //r.xMax = lw - 4;
            r.height = 16;
            //r.xMax -= 18;

            var name = property.FindPropertyRelative("name");

            EditorGUI.BeginDisabledGroup(name.stringValue == WorldBoundsGroup.defaultName);
            string n = EditorGUI.DelayedTextField(r, /*gngc,*/ name.stringValue);

            EditorGUI.EndDisabledGroup();

            if (n != name.stringValue)
            {
                Undo.RecordObject(property.serializedObject.targetObject, "Undo World Bounds Group name change.");
                haschanged       = true;
                name.stringValue = n;

                property.serializedObject.ApplyModifiedProperties();
                WorldBoundsSettings.EnsureNamesAreUnique();
                property.serializedObject.Update();
            }

            r.y    += 18;
            r.xMax += 18;

            if (haschanged)
            {
                EditorUtility.SetDirty(property.serializedObject.targetObject);
                //AssetDatabase.SaveAssets();
            }
        }