/// <summary> /// 添加“空间限制” /// </summary> public SpaceLimit AddSpaceLimit() { if (spaceLimit == null) { spaceLimit = OperaObject.GetComponent <SpaceLimit>() ?? OperaObject.AddComponent <SpaceLimit>(); } spaceLimit.hideFlags = HideFlags.HideInInspector; return(spaceLimit); }
/// <summary> /// 空间限制面板显示 /// </summary> private void InspectorSpaceLimit() { if (features.ActiveSpaceLimit) { _spaceLimit = features.AddSpaceLimit(); if (_spaceLimit == null) { return; } EditorGUILayout.BeginVertical(); _spaceLimit.limitObj = EditorGUILayout.ObjectField(" *被限制的物体", _spaceLimit.limitObj, typeof(GameObject), true) as GameObject; if (_spaceLimit.limitObj == null) { EditorGUILayout.HelpBox("请赋值被抓取物体本身", MessageType.None, false); } EditorGUILayout.BeginHorizontal(); _spaceLimit.topLimit = EditorGUILayout.Toggle(" *上边限制", _spaceLimit.topLimit); _spaceLimit.topOffset = EditorGUILayout.FloatField(" 上偏移量", _spaceLimit.topOffset); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _spaceLimit.bottomLimit = EditorGUILayout.Toggle(" *下边限制", _spaceLimit.bottomLimit); _spaceLimit.bottomOffset = EditorGUILayout.FloatField(" 下偏移量", _spaceLimit.bottomOffset); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _spaceLimit.leftLimit = EditorGUILayout.Toggle(" *左边限制", _spaceLimit.leftLimit); _spaceLimit.leftOffset = EditorGUILayout.FloatField(" 左偏移量", _spaceLimit.leftOffset); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _spaceLimit.rightLimit = EditorGUILayout.Toggle(" *右边限制", _spaceLimit.rightLimit); _spaceLimit.rightOffset = EditorGUILayout.FloatField(" 右偏移量", _spaceLimit.rightOffset); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } else { features.RemoveSpaceLimit(); _spaceLimit = null; } }